ZOJ 1057 水题~ 在编译器上正确输出 为啥一提交就WA~~坐等大人解答~
发布网友
发布时间:2022-04-14 15:47
我来回答
共2个回答
热心网友
时间:2022-04-14 17:16
#include "stdafx.h"
#include<stdio.h>
int main(int argc, char* argv[])
{
int n;
int hold_A[20],hold_B[20];
int total_a, total_b;
scanf("%d", &n);
while( n ){
total_a = 0;
total_b = 0;
for( int i=0; i<n; i++)
scanf("%d",&hold_A[i]);
for( int k=0; k<n; k++)
scanf("%d", &hold_B[k]);
for( int m=0; m<n; m++){
if( hold_A[m] - hold_B[m] == 1){
if( (hold_A[m]==2) && (hold_B[m]==1) )
total_b += 6;
else
total_b += hold_A[m] + hold_B[m];
}
else if( hold_B[m] - hold_A[m] == 1 ){
if( (hold_B[m]==2) && (hold_A[m]==1) )
total_a += 6;
else
total_a += hold_A[m] + hold_B[m];
}
else if( hold_A[m] > hold_B[m] ){
total_a += hold_A[m];
}
else if( hold_A[m] < hold_B[m] ){
total_b += hold_B[m];
}
else{
}
}
printf( "A has %d points. B has %d points.\n", total_a, total_b);
scanf("%d",&n);
if(n)
printf("\n");
}
return 0;
}
试一下这段代码如何?请将测试结果告诉我,谢谢
我怀疑是最后输出那个空行作怪追问编译有误~
追答有啥误啊
热心网友
时间:2022-04-14 18:34
太复杂了追问~ 汗
追答嘿嘿。。。看不懂啊