⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cc.txt

📁 上次站长没用!今次打包几个ACM的资料在上传
💻 TXT
字号:
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
main()
{
int a[4],b[4];
int k=0,t=0,r=0,i,j,p=0;
char ch;

do{ if(p==0)     {printf("\n*********************\n");
                printf("*welcome to the game*\n");
       printf("*********************\n");}

       do{
            srand((unsigned)time(NULL));
         a[0]=rand()%10;
         a[1]=rand()%10;
         a[2]=rand()%10;
         a[3]=rand()%10;
    }while(a[0]==a[1]||a[0]==a[2]||a[0]==a[3]||a[1]==a[2]||a[1]==a[3]||a[2]==a[3]);
    printf("%d %d %d %d",a[0],a[1],a[2],a[3]);
do{
   printf("\nplease input four number(0-9):");
   scanf("%d%d%d%d",&b[0],&b[1],&b[2],&b[3]);
                 getchar();
                 if(b[0]==b[1]||b[0]==b[2]||b[0]==b[3]||b[1]==b[2]||b[1]==b[3]||b[2]==b[3])
     printf("error!!!!please in put four different number!");
   else
   {
    r++;
       for(i=0;i<4;i++)
    for(j=0;j<4;j++)
    {if((j==i)&&(b[j]==a[i])) k++;
     if((j!=i)&&(b[j]==a[i])) t++;
    }
    printf("%d个全对,另外有%d个数字对,但位置错。",k,t);
    if(k!=4)
    {k=0;
    t=0;}
         }
}while((r<=8)&&(k!=4));
if((r==9)&&(k!=4))
         printf("\n try you best next time!!!\nthe trut answer is:%d %d %d %d",a[0],a[1],a[2],a[3]);
if(k==4) printf("\n you are so smart!!!!");
p++;
printf("\ndo you want play it again(Y/N)?");
ch=getchar();
k=0;t=0;
r=0;
}while(ch=='y'||ch=='Y');
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -