请教大家一个问题:
我的代码是这样的:
#include<iostream>
using namespace std;
int main()
{
int i, j,a[3][10];
for (i = 0; i < 3; i++)
{
for (j = 0; ; j++)
{
cin >> a[i][j];
if (a[i][j] != 0)
continue;
else break;
}
}
int max = 0;
for (i = 0; i < 3; i++)
{
for (j = 0; j < 10; j++)
{
if (max >= a[i][j])
continue;
else max = a[i][j];
if (a[i][j] != 0)
continue;
else break;
}
cout << max << endl;
max = 0;
}
return 0;
}
在vs上运行成功,但是oj上显示“答案错误”,可以帮我看看是什么问题吗?
and 可以告诉我一点oj的技巧就更好了,我经常在vs上运行成功,但是oj过不了。
题目要求是多行输入,而代码里只循环了三次而已
附一下自己写的代码
#include <cstdio>
int main()
{
int input = 0, _max = 0;
while (scanf ("%d", &input) != EOF) {
if (input > _max) _max = input;
if (input == 0) {
printf("%d\n", _max);
_max = 0;
}
}
return 0;
}