訪客只能看到部份內容,免費 加入會員 或由臉書 Google 可以看到全部內容
#include<time.h> char* card (int n) { static char num[] = {0,0}; switch(n){ case 1: return "A"; case 10: return "10"; case 11: return "J"; case 12: return "Q"; case 13: return "K"; default: num[0] = n+Ɔ' } return num; } int main(void) { int me ,pc; srand(time(0)); while (1){ printf("您的牌= %s", card (me=rand()%13+1)); printf (" 電腦牌=%s\n", card (pc=rand()%13+1)); if (me>pc) printf("★You Win★╭∩╮_(︶︿︶)_╭∩╮\n"); else printf("◆You Lose◆╮(╯▽╰)╭\n"); getchar();} system("PAUSE"); return 0; }
下面是引用daviddr於2008-05-31 23:56發表的 : 這樣寫如何?[code]#include<time.h>char* card (int n){ static char num[] = {0,0};.......