69,373
社区成员
发帖
与我相关
我的任务
分享
//仅供参考:
#include<stdio.h>
int main(){
int N;
int a,b;
int win=0,lose=0,draw=0;
scanf("%d",&N);
while(N--){
scanf("%d%d",&a,&b);
switch(a-b){
case -1:++win;break;
case 2:++win;break;
case -2:++lose;break;
case 1:++lose;break;
case 0:++draw;break;
default:break;
}
}
printf("%d\n%d\n%d\n",win,draw,lose);
}
#include <stdio.h>
#include <stdlib.h>
int main()
{
int n,i,j;
int win = 0, fall = 0, flat = 0;
printf("please input the num of the games: ");
scanf("%d", &n);
if( !(n >= 0 && n <= 1000) )
{
printf("please input the num 0 to 1000\n");
exit(1);
}
while(n--)
{
printf("please input what the bingbing show: ");
scanf("%d", &i);
if( !(i >= 0 && i <= 2) )
{
printf("please input the num 0 to 2\n");
exit(1);
}
printf("please input what the others show: ");
scanf("%d", &j);
if( !(j >= 0 && j <= 2) )
{
printf("please input the num 0 to 2\n");
exit(1);
}
if(0 == i)
{
if(0 == j)
flat++;
else if (1 == j)
win++;
else
fall++;
}
else if(1 == i)
{
if(0 == j)
fall++;
else if (1 == j)
flat++;
else
win++;
}
else if(2 == i)
{
if(0 == j)
win++;
else if (1 == j)
fall++;
else
flat++;
}
}
printf("The num of the win are %d\n", win);
printf("The num of the fall are %d\n", fall);
printf("The num of the flat are %d\n", flat);
}
还可以把exit换成goto