#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int func(){
int a,b;
a=rand()%6+1;
b=rand()%6+1;
if(a==b&&a==6){
return 8;
}else if(a==b){
return 7;
}else{
return (a<b?a:b);
}
}
void main(){
int sumA,sumB,i;
sumA=sumB=0;
srand(time(0));
for(i=0;i<10;i++){
sumA+=func();
sumB+=func();
if(i==4){
if(sumA>1.3*sumB){
printf("A:%d\nB:%d\n5局A获胜\n",sumA,sumB);
return;
}else if(sumB>1.3*sumA){
printf("A:%d\nB:%d\n5局B获胜\n",sumA,sumB);
return;
}
}
}
if(sumA>sumB){
printf("A:%d\nB:%d\n10局A获胜\n",sumA,sumB);
}else if(sumB>sumA){
printf("A:%d\nB:%d\n10局B获胜\n",sumA,sumB);
}else{
printf("A:%d\nB:%d\n平局\n",sumA,sumB);
}
return;
}
温馨提示:答案为网友推荐,仅供参考