1.用C语言编程扑克牌搓点游戏,急
给你修改好了。
20分,有点少了,呵呵。/*游戏:扑克牌搓点游戏 规则:您将随机抽取其中两张和电脑进行对抗,2张牌相加,个位大的胜出,其中对子比单牌大,若都是对子,对子大的胜出。
您可以根据提示下注,起始资金均为1000元,当一方财产小于0时,宣布破产,另一方胜出。作者:于吉祥 日期:20090220*/#include #include #include #define MAX_M 1000 enum colour { HEI = 0, HONG, MEI, FANG,}; void display(int number , int sign) { printf("%s\n","╭——╮"); switch(number) { case 0: printf("%s\n","│0 │"); break; case 1: printf("%s\n","│A │"); break; case 2: printf("%s\n","│2 │"); break; case 3: printf("%s\n","│3 │"); break; case 4: printf("%s\n","│4 │"); break; case 5: printf("%s\n","│5 │"); break; case 6: printf("%s\n","│6 │"); break; case 7: printf("%s\n","│7 │"); break; case 8: printf("%s\n","│8 │"); break; case 9: printf("%s\n","│9 │"); break; case 10: printf("%s\n","│10 │"); break; case 11: printf("%s\n","│J │"); break; case 12: printf("%s\n","│Q │"); break; case 13: printf("%s\n","│K │"); break; default: printf("error"); break; }// printf("%s\n","│ │"); printf("%s","│ "); switch(sign) { case HEI: printf("%c",06); break; case HONG: printf("%c",03); break; case MEI: printf("%c",05); break; case FANG: printf("%c",04); break; default: break; } printf("%s\n"," │"); printf("%s\n","│ │"); printf("%s\n","╰——╯"); } int compare(int x[] , int y[]) { int sign,a,b; if((x[0] == x[1])&&(y[0] == y[1])) { if(x[0] == y[0]) sign = 0; else if(x[0] > y[0]) sign = 1; else sign = -1; } else if(x[0] == x[1]) sign = 1; else if(y[0] == y[1]) sign = -1; else { a = (x[0]+x[1])%10; b = (y[0]+y[1])%10; if(a == b) sign = 0; else if(a > b) sign = 1; else sign = -1; } return sign; } void main() { int i,chip; int Per[2],Com[2]; int Mon_Per = MAX_M , Mon_Com = MAX_M; int Colour_Per[2] , Colour_Com[2]; printf("扑克牌搓点游戏\n"); printf("---------------\n"); system("pause"); while(1) { system("cls"); if(Mon_Per <=0) { printf("您已身无分文,游戏退出!"); break; } if(Mon_Com <=0) { printf("电脑已经被你赢光了,恭喜你获胜!"); break; } srand( time(NULL) ); for(i=0;i<2;i++) { Per[i] = rand()%13+1; Colour_Per[i] = rand()%4; Com[i] = rand()%13+1; Colour_Com[i] = rand()%4; } printf("当前余额:你(%d),电脑(%d)\n",Mon_Per,Mon_Com);// printf("牌已经抽取,你抽到的牌为:%d %d\n",Per[0],Per[1]); printf("牌已经抽取,你抽到的牌为:\n"); for(i=0;i<2;i++) display(Per[i],Colour_Per[i]); printf("请下注:"); RET: scanf("%d",&chip); if(chip>500) { printf("最大可下注为500,请重新下注!\n"); goto RET; } Mon_Per -= chip; Mon_Com -= chip; if(Mon_Per < 0) { printf("您的余额不足,请重新下注!"); Mon_Per += chip; Mon_Com += chip; goto RET; } if(Mon_Com < 0) { printf("电脑余额不足,请重新下注!"); Mon_Per += chip; Mon_Com += chip; goto RET; } switch(compare(Per,Com)) { case 0: printf("平局!"); Mon_Per += chip; Mon_Com += chip; break; case 1: printf("你赢了!"); Mon_Per += 2*chip; break; case -1: printf("电脑赢了!"); Mon_Com += 2*chip; break; default: printf("系统出错!"); break; }// printf("电脑抽到的牌为:%d %d\n",Com[0],Com[1]); printf("电脑抽到的牌为:\n"); for(i=0;i<2;i++) display(Com[i],Colour_Com[i]); system("pause"); } printf("游戏结束!"); system("pause"); }。
2.求高手翻译一小段摘要,急用本论文以传统纸牌游戏的规则为基础,
Abstract ,-cardgame--gongzhu,, histheroy,listedthecontent,,/StoB/S,foundthec/ ,otherwise the strongpoint of B/ en decided to use B/S to develop this d adopt the Socket technology of Java to carry out the communication between customer and application server 。
Also make clear explain of the system and plot out the function module which were detail designed 。
3.如何用C语言编写一个24点的游戏
我可以用C++帮你编一个这样的小程序 但不知道C++算不算得上是C语言?这个程序有些笨,它无法分辨重复的牌,只能简单进行计算。
但结果是没问题的虽然和你需要的有点出入,但是下面的小程序也算是提供一种思路吧#includeusing namespace std;int main(){int i1,i2,i3,i4,v,n1,n2;double t1,t2,t3,t4,choice[4],s1[4],s2[4][4];cout<<"##########################二十四点全解###################################\n友情提示:A=1,J=11,Q=12,K=13\n";cout<<"请说出你抽到的第一牌:";cin>>choice[0];cout<<"请说出你抽到的第二牌:";cin>>choice[1];cout<<"请说出你抽到的第三牌:";cin>>choice[2];cout<<"请说出你抽到的第四牌:";cin>>choice[3];cout<<"########################## THINKING ###################################\n";for(i1=0;i1<4;i1++){t1=choice[i1];for(i2=0;i2<4;i2++){if(i2!=i1){t2=choice[i2];s1[0]=t1+t2;s1[1]=t1-t2;s1[2]=t1*t2;s1[3]=t1/t2;for(i3=0;i3<4;i3++){if(i3!=i1&&i3!=i2){t3=choice[i3];for(v=0;v<4;v++){s2[v][0]=s1[v]+t3;s2[v][1]=s1[v]-t3;s2[v][2]=s1[v]*t3;s2[v][3]=s1[v]/t3;}for(i4=0;i4<4;i4++){if(i4!=i1&&i4!=i2&&i4!=i1){t4=choice[i4];for(n1=0;n1<4;n1++)for(n2=0;n2<4;n2++)if(s2[n1][n2]+t4==24||s2[n1][n2]-t4==24||s2[n1][n2]*t4==24||s2[n1][n2]/t4==24){cout<<"找到一种组合方案:\n(("<
4.急需一个C语言 猜拳游戏的源代码
enum p_r_s{ paper,rock,scissors,game,help,instructions,quit};#include main(){ enum p_r_s player,machine; enum p_r_s selection_by_player(),selection_by_machine(); int win,lose,tie; win=lose=tie=0; instructions_for_the_player(); while((player=selection_by_player())!=quit) switch(player){ case paper: case rock: case scissors: machine=selection_by_machine(); if(player==machine){ ++tie; printf("\n a tie"); } else if(you_won(player,machine)){ ++win; printf("\n you won"); } else{ ++lose; printf("\n i won"); } break; case game: game_status(win,lose,tie); break; case instructions: instructions_for_the_player(); break; case help: help_for_the_player(); break; } game_status(win,lose,tie); printf("\n\nBYE\n\n");} instructions_for_the_player() { printf("\n%s\n\n%s\n\n%s\n%s\n%s\n\n%s\n%s\n%s\n\n%s\n%s\n%s", "PAPER,ROCK,SCISSORS", "In this game", "p is for paper,", "r is for rock,", "s is for scissors.", "Both the player and the machine will choose one", "of p,r,or s. If the two choices are the same,", "then the game is a tie. Otherwise:", "\"paper covers the rock\" (a win for paper),", "\"rock breaks the scissors\" (a win for rock),", "\"scissors cut the paper\" (a win for scissors)."); printf("\n\n%s\n\n%s\n%s\n%s\n%s\n\n%s\n\n%s", "There are other allowable inputs:", "g for game status (the number of wins so far),", "h for help,", "i for instructions (reprin these instructions),", "q for quit (to quit the game).", "This game is played repeatedly until q is entered.", "Good luck!"); } enum p_r_s selection_by_player() { char c; enum p_r_s player; printf("\n\ninput p,r,or s:"); while((c=getchar())==''||c=='\n'||c=='t'); ; switch(c){ case 'p': player=paper; break; case 'r': player=rock; break; case 's': player=scissors; break; case 'g': player=game; break; case 'i': player=instructions; break; case 'q': player=quit; break; default: player=help; } return(player); } enum p_r_s selection_by_machine() { static int i; i=++i%3; return((i==0)? paper:((i==1)? rock:scissors)); } you_won(player,machine) enum p_r_s player,machine; { int victory; if(player==paper) victory=machine==rock; else if(player==rock) victory=machine==scissors; else/*player==scissors*/ victory=machine==paper; return(victory); } game_status(win,lose,tie) { printf("\nGAME STATUS"); printf("\n\n%7d%s\n%7d%s\n%7d%s\n%7d%s", win,"games won by you", lose,"games won by me", tie,"game tied", win+lose+tie,"games played:"); } help_for_the_player() { printf("\n%s\n\n%s\n%s\n%s\n%s\n%s\n%s\n%s", "the following characters can be used for input:", " p for paper", " r for rock", " s for scissors", " g to find out the game status", " h to print this list", " i to reprint the instructions for this game", " q to quit this game"); }。

转载请注明出处众文网 » 毕业论文用c开发扑克牌游戏