所以你要啥子码 图裂了
前排提示百度啥都有
#include<stdio.h> #include<stdlib.h> #include<time.h> int checknum(int a,int b,int c,int d) { if(a>6||b>6||c>6||d>6||a<0||b<0||c<0||d<0) return 1; if(c==0&&d==0) return 0; if(c>a||(c==a&&d>b)) return 0; else return 1; } void catchlier(int a,int b,int *p,int o) { int i,m=0,n=0; for(i=0;i<6;++i,*(p++)) { if(*p==1) m++; if(*p==b) n++; } if(n>=a) printf("Loser is %c. (Without optional rules)\n",o); else printf("Loser is %c. (Without optional rules)\n",o>65?o-1:67); if(m+n>=a) printf("Loser is %c. (With optional rules)\n",o); else printf("Loser is %c. (With optional rules)\n",o>65?o-1:67); } int main(void) { int points[6],i,n=65,j=0; int a,b,c,d; srand((unsigned)time(NULL)); for(i=0;i<6;++i) points[i]=rand()%6+1; printf("A's turn: A has %d and %d\n",points[0],points[1]); scanf("%d%d",&a,&b); while(1) { j++; n++; if(n>67) n=65; if(j>2) j=1; printf("%c's turn: %c has %d and %d\n",n,n,points[j*2],points[j*2+1]); scanf("%d%d",&c,&d); while(checknum(a,b,c,d)) { printf("Invalid input.\n"); printf("%c's turn: %c has %d and %d\n",n,n,points[j*2],points[j*2+1]); scanf("%d%d",&c,&d); } if(c==0&&d==0) break; a=c; b=d; } printf("All dices:"); for(i=0;i<6;++i) printf("%d ",points[i]); putchar('\n'); catchlier(a,b,points,n); return 0; }