关于数字游戏的到判断时不会了,求请教!
程序代码:
#include<stdio.h> #include<stdlib.h> #include<time.h> void NumTochar(); void guess(); int rang(); void judge(); void print(); int main() { int P,count; NumTochar(); guess(); rang(); printf("previous points;%d\n",P); printf("\n Guess Type Number Amont \n"); for(count=1;count<=5;count++) { judge(); print(); } return 0; } void NumTochar()//将相应的的数字用字母表示,底 L(1-12),中M(13-24),高H(25-36)左F(1-34)(每隔3个数,1,4,7,10,,,34), //中C(2-35)(每隔3个数,2,5,,,35),右R(3-36)(每隔3个数,3,6,9,,36),所有数字N(1-36),O(1到36中的奇数),E(1到36中的偶数) { char Type; int i; int l[11]={1,2,3,4,5,6,7,8,9,10,12}; int m[12]={13,14,15,16,17,18,19,20,21,22,23,24}; int h[12]={25,26,27,28,29,30,31,32,33,34,35,36}; int f[12]={1,4,7,10,13,16,19,22,25,28,31,34}; int c[12]={2,5,8,11,14,17,20,23,26,29,32,35}; int r[12]={3,6,9,12,15,18,21,24,27,30,33,36}; int b[36]={1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36}; int o[18]={1,3,5,7,9,11,13,15,17,19,21,23,25,27,29,31,33,35}; int e[18]={2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32,34,36}; if(l[0]=1 && l[i]<=12) Type='L'; if(m[0]=13 && m[i]<=24) Type='M'; if(h[0]=25 && h[i]<=36) Type='H'; if(f[0]=1&&f[i-1]+3&&f[i]<=34) Type='F'; if(c[0]=2&&e[i-1]+3&&e[i]<=35) Type='C'; if(r[0]=3&&r[i-1]+3&&r[i]<=36) Type='R'; if(b[0]=1&&b[i]<=36) Type='N'; if(o[0]=1&&o[i-1]+2&&o[i]<=35) Type='O'; if(e[0]=2&&e[i-1]+2&&e[i]<=36) Type='E'; } void guess()//猜测 高中底左中右奇偶或确切的数字 { int p,count,P,P1,i,b[36]; char Type; printf("how many would you like; \n ");//开始将的分数 scanf("%d",&P); printf("you can guess 5;\n");//5次机会 for(count=1;count<=5;count++) { printf("enter you choice");//猜测 scanf("%c",&Type); if(Type='N') { printf("enter you number;");//如果才确切的数字就请输入数字 scanf("%d",&b[i]); } printf("points at risk;");//你押的分数 scanf("%d",p); if(P<p)//如果押的分数大于给的分数则错误 { printf("ERROR"); printf("please enter at risk;"); scanf("%d",&p); P1=P-p; } } } int rang()//产生随机数 { int rangNo,range; srand(time(NULL)); range=36; rangNo=rand()%range+1; printf("my number is %d;\n",rangNo); return(rangNo); } /* void judge()//进行判断,,,,,就这不会了!试了两种方法都错误 { int P0,P1,P,p,rangNo,i,Type,j; int l[12],m[12],h[12],f[12],c[12],r[12],b[36],o[18],e[18]; switch(rangNo) //for(j=1;j<=12;j++) case 1: if(Type=='L'&&Type='O'&&Type='F') P0=P1+2*p; case 2: if(Type='L'&&type='E'&&type='C') P0=P1+2*p; case 3: if(Type='L'&&type='O'&&type='R') P0=P1+2*p; case 4: if(Type='L'&&type='E'&&type='F') P0=P1+2*p; case 5: if(Type='L'&&type='O'&&type='C') P0=P1+2*p; case 6: if(Type='L'&&type='E'&&type='R') P0=P1+2*p; case 7: if(Type='L'&&type='O'&&type='F') P0=P1+2*p; case 8: if(Type='L'&&type='E'&&type='C') P0=P1+2*p; case 9: if(Type='L'&&type='O'&&type='R') P0=P1+2*p; case 10:if(Type='L'&&type='E'&&type='F') P0=P1+2*p; case 11: if(Type='L'&&type='O'&&type='C') P0=P1+2*p; case 12: if(Type='L'&&type='E'&&type='R') P0=P1+2*p; case 13: if(Type='M'&&type='O'&&type='F') P0=P1+2*p; case 14: if(Type='M'&&type='E'&&type='C') P0=P1+2*p; case 15: if(Type='M'&&type='O'&&type='R') P0=P1+2*p; case 16: if(Type='M'&&type='E'&&type='F') P0=P1+2*p; case 17: if(Type='M'&&type='O'&&type='C') P0=P1+2*p; case 18: if(Type='M'&&type='E'&&type='R') P0=P1+2*p; case 19: if(Type='M'&&type='O'&&type='F') P0=P1+2*p; case 20: if(Type='M'&&type='E'&&type='C') P0=P1+2*p; case 21: if(Type='M'&&type='O'&&type='R') P0=P1+2*p; case 22: if(Type='M'&&type='E'&&type='F') P0=P1+2*p; case 23: if(Type='M'&&type='O'&&type='C') P0=P1+2*p; case 24: if(Type='M'&&type='E'&&type='R') P0=P1+2*p; case 25: if(Type='H'&&type='O'&&type='F') P0=P1+2*p; case 26: if(Type='H'&&type='E'&&type='C') P0=P1+2*p; case 27: if(Type='H'&&type='O'&&type='R') P0=P1+2*p; case 28: if(Type='H'&&type='E'&&type='F') P0=P1+2*p; case 29: if(Type='H'&&type='O'&&type='C') P0=P1+2*p; case 30: if(Type='H'&&type='E'&&type='R') P0=P1+2*p; case 31: if(Type='H'&&type='O'&&type='F') P0=P1+2*p; case 32: if(Type='H'&&type='E'&&type='C') P0=P1+2*p; case 33: if(Type='H'&&type='O'&&type='R') P0=P1+2*p; case 34: if(Type='H'&&type='E'&&type='F') P0=P1+2*p; case 35: if(Type='H'&&type='O'&&type='C') P0=P1+2*p; case 36: if(Type='H'&&type='E'&&type='R') P0=P1+2*p; */ /*if(Type='L') P0=P1+2*p; case (m[i]=rangNo): if(Type='M') P0=P1+2*p; case h[i]=rangNo: if(Type='H') P0=P1+2*p; case f[i]=rangNo: if(Type='F') P0=P1+2*p; case c[i]=rangNo: if(Type='C') P0=P1+2*p; case r[i]=rangNo: if(Type='R') P0=P1+2*p; case o[i]=rangNo: if (Type='O') P0=P1+p; case e[i]=rangNo: if(Type='E') P0=P1+p; case b[i]=rangNo: if(Type='E'&&rangNo==b[i]) P0=P1+36*p; default : printf("ERROR"); }*/ void print()//打印 { int count,b[36],p,i; char Type; printf("%d %c %d %d",count,Type,b[i],p); }