| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 310 人关注过本帖
标题:一个小程序,但错误很多,哪位高手可以帮我改下啊,谢了!
只看楼主 加入收藏
guxinxiaohan
Rank: 2
等 级:论坛游民
帖 子:6
专家分:12
注 册:2010-5-11
收藏
 问题点数:0 回复次数:0 
一个小程序,但错误很多,哪位高手可以帮我改下啊,谢了!
#include <stdio.h>
#include <stdio.h>
#include <stdio.h>

#define maxtime 8
#define winer 1
#define loser 0

int main()
{
int aid[4],num[4],i,j,times,key,key2,A,B;
char ch;
time_t now;

Initialize:now=time(0);
srand(now);
aid[0]=(rand()+90)%10;
delay(20);
aid[1]=(rand()+90)%10;
delay(20);
aid[2]=(rand()+90)%10;
delay(20);
aid[3]=(rand()+90)%10;
for(i=0;i<4;i++)
{for(j=0;j<4;j++)
{if((i!=j)&&(aid[i]==aid[j]))
goto Initialize;
}
}
printf(nnn);

times=1;
while(times<=MAXTIMES)
{
key=0;
key2=0;
printf(NO.%d:ntPlease input 4 different int numbers to play!nt,times);
scanf(%d,%d,%d,%d,&num[0],&num[1],&num[2],&num[3]);

for(i=0;i<4;i++)
{
if(!((num[i]<=9)&&(num[i]>=0)))
{
printf(tError!The numbers you input must be int numbers which from 0 to 9n);
key=1;
break;
}
}
if(key==1)
continue;

for(i=0;i<4;i++)
{
for(j=i+1;j<4;j++)
{
if(num[i]==num[j])
{printf(tError!The numbers you input must be different!n);
key2=1;
}
break;
}
}
if(key2==1)
continue;

A=0;
B=0;

for(i=0;i<4;i++)
{
if(num[i]==aid[i])
A++;
}
for(i=0;i<4;i++)
{
for(j=0;j<4;j++)
{
if(num[i]==aid[j])
B++;
}
}
B=B-A;
printf(tA%dB%dn,A,B);

if(A==4)
{
printf(Congratulations!n);
printf(Press any key to exit.!na);
getch();
return(winer);
}
else
{
printf(Press ENTER to continue,or press A to see about answer and exit.n); /*选择是否放弃,看答案*/
ch=getch();
if(ch=='n')
{
continue;
}
if((ch=='a')||(ch=='A'))
{
printf(The four numbers:%d,%d,%d,%dn,aid[0],aid[1],aid[2],aid[3]);
getch();
return(loser);
}
}

times++;
}

printf(Sorry!You have lost all the chances!nPress any key to exit!n);
getch();
}
搜索更多相关主题的帖子: aid include loser 
2010-05-25 17:51
快速回复:一个小程序,但错误很多,哪位高手可以帮我改下啊,谢了!
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.011094 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved