精華區beta b885060xx 關於我們 聯絡資訊
以下是我的程式. 如果還沒寫完就不要看吧. 還有, 如果你想抄去用修改的, 建議是不要. 因為我用了太多理論上應該還沒有教到的東西. 並且寫法也很不是其他風格的人會這樣寫的. 還有, 我還不確定有沒有Bug呢... #include <stdio.h> #include <string.h> #include <ctype.h> #include <conio.h> #define COMMANDS 8 void show(int, int, char *, int); char message[50]; int mode; int choice; long save[4]; int key; int quit; char ch[COMMANDS][31] = {"Original", "Government", "Enterprise", "Quit", " Local call(min):", "loNg-distance call(sec):", "International call(sec):", " Pay:"}; int xy[COMMANDS][2] = {{10, 3}, {30, 3}, {50, 3}, {5, 1}, {10, 6}, {10, 7}, {10, 8}, {10, 10}}; int main(void) { int i; clrscr(); for(;;) { save[3] = 0; switch(choice) { case 0: save[3] += (save[0] % 3 == 0) ? (save[0] / 3) : (save[0] / 3 + 1) save[3] += (save[1] % 10 == 0) ? (save[1] / 10) : (save[1] / 10 + save[3] += (save[2] % 5 == 0) ? (save[2] / 5) : (save[2] / 5 + 1) if(save[3] < 100) save[3] = 100; break; case 1: save[3] += (save[0] % 3 == 0) ? (save[0] / 3) : (save[0] / 3 + 1) save[3] += (save[1] % 10 == 0) ? (save[1] / 10) : (save[1] / 10 + save[3] *= 8; save[3] /= 10; save[3] += (save[2] % 5 == 0) ? (save[2] / 5) : (save[2] / 5 + 1) if(save[3] < 500) save[3] = 500; break; case 2: save[3] += (save[0] % 3 == 0) ? (save[0] / 3) : (save[0] / 3 + 1) save[3] += (save[1] % 10 == 0) ? (save[1] / 10) : (save[1] / 10 + save[3] += ((save[2] % 5 == 0) ? (save[2] / 5) : (save[2] / 5 + 1 if(save[3] < 1000) save[3] = 1000; break; } for(i = 0; i < COMMANDS; i++) show(xy[i][0], xy[i][1], ch[i], (i == mode) ? (1) : (0)); for(i = 4; i <= 7; i++) { sprintf(message, "%ld ", save[i - 4]); show(xy[i][0] + 25, xy[i][1], message, 1); } gotoxy(1, 1); if(quit == 1) break; switch(mode) { case 4: case 5: case 6: gotoxy(xy[mode][0] + 25, xy[mode][1]); printf(" "); gotoxy(xy[mode][0] + 25, xy[mode][1]); scanf("%ld", &save[mode - 4]); mode = choice; continue; } if((key = getch()) == '\0') key = getch(); switch(toupper(key)) { case 'O': mode = choice = 0; break; case 'G': mode = choice = 1; break; case 'E': mode = choice = 2; break; case 'Q': mode = 3; quit = 1; break; case 'L': mode = 4; break; case 'N': mode = 5; break; case 'I': mode = 6; break; } } show(1, 22, "Thanks for your use!\r\n", 1); return(0); } void show(int x, int y, char *str, int st) { int i; if(st == 0) { gotoxy(x, y); for(i = 0; i < strlen(str); i++) { textcolor(7 + 8 * ((isupper(str[i])) ? (1) : (0))); cprintf("%c", str[i]); } } else { gotoxy(x, y); textcolor(14); cprintf("%s", str); textcolor(7); } } -- 有機會而不仔細的看動漫畫的每一個畫面, 動漫畫的世界不限定在紙和螢幕上, 如果心的回響足夠的話, 就如同有機會向那流星許願, 卻錯過了般的可惜... 它只是還沒跳出來, 到你或妳的心中罷了... 動漫畫就不再是動漫畫, 而是聽你或妳說話的心了... -- ※ 發信站: 批踢踢實業坊(ptt.twbbs.org) ◆ From: ntucsa.csie.ntu.edu.tw