在线观看www成人影院-在线观看www日本免费网站-在线观看www视频-在线观看操-欧美18在线-欧美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%

      發表評論

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

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

      ?
      主站蜘蛛池模板: 天天做天天做天天综合网| 天堂网www在线资源网| 久久国产精品久久久久久| 免费a在线看| 九色精品在线| 国产成人高清一区二区私人| 4hu影院最新地址www| 五月天狠狠| 国产亚洲美女精品久久久久狼| 色最快国产| 天堂精品视频| 欧美性喷潮xxxx| 激情综合五月婷婷| 又大又粗又爽黄毛片| 三a大片| 高清一本之道加勒比在线| 天天干在线影院| 欧美一级在线全免费| 91成人免费福利网站在线| 永久免费看黄| 欧美另类激情| 日本不卡高清免费| 伊人网站在线| 色老久久精品偷偷鲁一区| 久久国模| 亚洲国产精品日韩专区avtube| aaa在线观看高清免费| 天天看片国产| 亚洲成a人片8888kkkk| 男人的亚洲天堂| 色综合网址| 黄色视屏在线免费播放| 午夜视频精品| 天天av天天翘天天综合网| 国产美女亚洲精品久久久综合 | 羞羞爱爱| 伦理一区二区三区| 亚洲午夜视频在线| 456成人网| 亚洲综合啪啪| 五月天激情开心网|