91在线观看视频-91在线观看视频-91在线观看免费视频-91在线观看免费-欧美第二页-欧美第1页

您好,歡迎來電子發燒友網! ,新用戶?[免費注冊]

您的位置:電子發燒友網>源碼下載>數值算法/人工智能>

人機猜數游戲源代碼

大小:155 人氣: 2010-02-09 需要積分:0
{$username}的空間

用戶級別:注冊會員

貢獻文章:

貢獻資料:

人機猜數游戲源代碼
#include "time.h"
#include "stdlib.h"
#include
#include
void guess1( )
{
?int Password=0,Number=0,price=58,i=0;
?clrscr();
?printf("\n====This is a Number Guess Game!====\n");
?while( Password != 1234 )
?{
??if( i >= 3 )
???return;
??i++;
??puts("Please input Password: ");
??scanf("%d",&Password);
?}
?
?i=0;
?while( Number!=price )
?{
??do{
???puts("Please input a number between 1 and 100: ");
???scanf("%d",&Number);
???printf("Your input number is %d\n",Number);
??}while( !(Number>=1 && Number<=100) );
??if( Number >= 90 )
??{
???printf("Too Bigger! Press any key to try again!\n");
??}
??else if( Number >= 70 && Number < 90 )
??{
???printf("Bigger!\n");
??}
??else if( Number >= 1 && Number <= 30 )
??{
???printf("Too Small! Press any key to try again!\n");
??}
??else if( Number > 30 && Number <= 50 )
??{
???printf("Small! Press any key to try again!\n");
??}
??else
??{
???if( Number == price )
???{
????printf("OK! You are right! Bye Bye!\n");
???}
???else if( Number < price )
???{
????printf("Sorry,Only a little smaller! Press any key to try again!\n");
?
???}
???else if( Number > price )
????printf(" Sorry, Only a little bigger! Press any key to try again!\n");
??}
??getch();
?}
}
?
void? guess2( )
{ int y,stime,a,z,t,i,c,m,g,s,j=0,k=0,b[4],l[4];
? long ltime;
? ltime=time(NULL);
? stime=(unsigned int)ltime/2;
? srand(stime);
? z=random(9999);
? printf("I have a number with 4 digits in mind,please guess.\n");
? for(c=1;;c++)
? { printf("Enter a number with 4 digits:");
??? scanf("%d",&g);
??? a=z;j=0;k=0;
??? l[0]=l[1]=l[2]=l[3]=0;
??? for (i=1;i<5;i++)
??? { s=g;m=1;
????? for (t=1;t<5;t++)
????? { if (a%10==s%10)
?{ if (m&&t!=l[0]&&t!=l[1]&&t!=l[2]&&t!=l[3])
?? { j++;m=0;l[j-1]=t;
?? }
?? if (i==t)

?
void swap1(float *p1,float *p2)
{float temp;
?temp=*p1;*p1=*p2;*p2=temp;
}
void swap2(char **p1,char **p2)
{char *temp;
?temp=*p1;*p1=*p2;*p2=temp;
}
void sort(char *code[],char *name[],float *score1,float *score2,
float *score3,float *aver,int n)
{int i,j;
?for (i=0;i?? for (j=i+1;j???? if (aver[i]???? { swap1(aver+i,aver+j) ;
?????? swap1(score1+i,score1+j);
?????? swap1(score2+i,score2+j);
?????? swap1(score3+i,score3+j);
?????? swap2(&name[i],&name[j]);
?????? swap2(&code[i],&code[j]);
???? }
簡易計算器源代碼
#include
int operator1,operator,first,second,result;
displaycalculator()
{clrscr();
?printf("+-------------------\n");
?printf("| Simple Caculator |\n");
?printf("+-------------------\n");
?printf("|????????????????? |\n");
?printf("+----+----+----|----\n");
?printf("|??? |? / |? * | - |\n");
?printf("+----+----+----|----\n");
?printf("|? 7 |? 8 |? 9 |?? |\n");
?printf("+----+----+----| + |\n");
?printf("|? 4 |? 5 |? 6 |?? |\n");
?printf("+----+----+----|---|\n");
?printf("|? 1 |? 2 |? 3 |?? |\n");
?printf("+----+----+----| = |\n");
?printf("|? 0????? |? . |?? |\n");
?printf("+---------+----|---|\n");
}
getdata()
{int c,n=0;
?do
?{ c=getch();
?? if (c>='0' && c<='9')
?? { putch(c);
???? n=n*10+c-0x30;
?? }
?? if (c=='\b' && wherex()>2)
?? { putch(c);putch(0x20);putch(c);
???? n/=10;
?? }
?}while (!(c==27||c=='+'||c=='-'||c=='*'||c=='/'||c=='\n'));
?operator=c;
?if (c!=27&&c!='\n') putch(c);
?return (n);
}
calculate()
{ if (operaor1=='+')
?? result=first+second;
? else if (operaor1=='-')
?? result=first-second;
? else if (operaor1=='*')
?? result=first*second;
? else
?? result=first/second;
}
displayresult()
{ gotoxy(2,4);
? printf("???????????? ");
? gotoxy(2,4);
? printf("%d",result);
? if (operator!=13 && operator!=27) putch(operator);
}
main()
{ displaycalculator();
? gotoxy(2,4);
? first=getdata();
? while (operator!=27)
? { operator1=operator;
??? second=getdata();
??? displayresult();
??? first=result;
? }

非常好我支持^.^

(8) 100%

不好我反對

(0) 0%

      發表評論

      用戶評論
      評價:好評中評差評

      發表評論,獲取積分! 請遵守相關規定!

      ?
      主站蜘蛛池模板: 福利社91 | 日本精品视频一视频高清 | 夜夜爽夜夜操 | 羞羞视频靠逼视频大全 | 正在播放久久 | 手机看片免费永久在线观看 | 国产免费播放 | 国产亚洲精品成人一区看片 | 欧美一级精品 | 日韩一二三级 | 亚洲欧洲一区二区三区在线 | 三级完整在线观看高清视频 | 真实女人寂寞偷人视频 | 中文字幕第页 | 99久久99久久精品国产 | 亚洲综合色dddd26 | 天天干夜夜爽天天操夜夜爽视频 | 日本最色视频 | 国产叼嘿网站免费观看不用充会员 | 深深激情网 | 午夜在线 | 亚洲1卡二卡3卡四卡不卡 | 日本黄色免费在线观看 | 日韩欧美视频在线一区二区 | 99久久99久久精品国产 | 国产第一页在线观看 | 免费激情网站 | 操干干| 天天精品视频在线观看资源 | 婷婷综合在线观看丁香 | 天堂在线www在线资源 | 97久草 | 午夜视频黄色 | 四虎影片国产精品8848 | 日本视频www色 | 34看网片午夜理 | 久久综合五月开心婷婷深深爱 | 欧美人与动性行为网站免费 | 刺激一区 | 免费恐怖片 | 国产a三级三级三级 |