我悲催的游戏程序啊,进来帮帮我吧,谢谢TT
#include<stdio.h>#include<stdlib.h>
#include<windows.h>
#include<string.h>
#include<time.h>
#include<process.h>
void putdata(char* a,int N)
{ int i;
srand((unsigned)time(0));/*控制产生不同的种子(包含于stdlib中)*/
for(i=0;i<N;i++)
a[i]=rand()%10;
for(i=0;i<N;i++)
printf("%d",a[i]);
Sleep(3000);/*数三秒(包含于stdlib中)*/
system("cls");/*清屏(包含于windows中)*/
}
void getdata(char *b,int N)
{ int i=0;
do
{ printf("put your number\n");
scanf("%d",&b[i]);
}
while(isdigit(b[i++])&&i<=N);/*当i是整数并且i小于N(请问为啥当我输入的是文字或输入很多数字都可以执行?)*/
}
int comdata(char*a,char*b,int N)
{ int i,count=0;
for(i=0;i<N;i++)
{if (strcmp(a,b)==0)
count++;
}
return count;
}
void getlevel(int n,int N)
{ printf("put the result\n");
switch(n/N*10)
{ case 10:
case 9 :printf("Great\n");break;
case 8 :printf("Very good\n");break;
case 7 :printf("Good\n");break;
default:printf("Come on\n");break;
}
}
void main(void)
{ char a[11],b[11];
int n,N;
system("color 67\n");
printf("How many numbers do you want to creat?(5or8or11)\n");
scanf("%d",&N);
printf("the original number are:\n");
putdata(a,N);
getdata(b,N);
n=comdata(a,b,N);
getlevel(n,N);
}