用java刷oj时碰到的一个问题
题目:
Input
There are multiple test cases. The first line of input contains an integer T indicating the number of test cases. For each test case:
The only line contains four integers ScoreA, ScoreB, ScoreC, and ScoreD - the four problems' score of the examinee.(0 <= ScoreA <= 20, 0 <= ScoreB, ScoreC <= 25, 0 <= ScoreD <= 30)
Output
For each test case, if the examinee gets 80 points or above in total, output "Yes", else output "No".
Sample Input
4
0 0 5 30
20 25 20 0
20 25 20 15
20 25 25 30
Sample Output
No
No
Yes
Yes
很简单的一个题目,我的java版代码:
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int row=in.nextInt();
int sum,tmp;
for(int i=0;i<row;i++){
sum=0;
for(int j=0;j<4;j++){
tmp=in.nextInt();
sum+=tmp;
}
if(sum>=80)
System.out.println("Yes");
else
System.out.println("No");
}
}
}
c语言版代码:
#include <stdio.h>
int main(){
int row;
scanf("%d",&row);
int sum,tmp;
for(int i=0;i<row;i++){
sum=0;
for(int j=0;j<4;j++){
scanf("%d",&tmp);
sum+=tmp;
}
if(sum>=80)
printf("Yes\n");
else printf("No\n");
}
}
java版的一直提示超时,后来用c语言写了下,立刻就过了,这是什么情况?是代码写错了,还是java效率差那么多?