how to use octave on hackerrank website?
이전 댓글 표시
hi there,
now I am trying to use octave to do the hackerrank test, but everytime I click on the 'Run code' button, it always says that 'no response on stdout', here is the code and note:
# Enter your code here. Read input from STDIN. Print output to STDOUT
a = stdin;
pivot = a(1);
equal = pivot;
left = a(a<pivot);
right = a(a>pivot);
stdout = [left equal right];
Does anyone knows this? Many thanks!
댓글 수: 7
Geoff Hayes
2020년 4월 17일
Weiqian - perhaps try usig printf instead. Also, is
stdout = [left equal right];
the correct syntax for using stdout?
Weiqian Jiang
2020년 4월 17일
Rik
2020년 4월 17일
Have you checked the Octave doc?
Geoff Hayes
2020년 4월 17일
You could try just
printf('<format_string>',yourVariables)
which should (?) print the output to stdout.
Weiqian Jiang
2020년 4월 18일
편집: Rik
2020년 4월 19일
Geoff Hayes
2020년 4월 19일
Weiqian - if you need exactly one space between each character then perhaps try something like
printf('%d', b(1));
for k = 2:length(b)
printf(' %d')
end
instead of disp.
Weiqian Jiang
2020년 4월 20일
답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Octave에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!