C語言問題

看板Programming作者時間18年前 (2008/01/27 11:01), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串1/2 (看更多)
請問高手們 題目如下: 輸入1到9之整數 , 列出此數在50以內之所有倍數 , 若輸入不是1到9之整數 , 則自動要求重新輸入 , 列印時每五個一列 , 敲F1鍵或ESC鍵則終止程式 -------------------------------------我是分隔線---------------------- 以下是我的程式: #include <stdio.h> void main(void) { int i; int j; printf("Please enter a number\n"); printf("Enter ESC to end the program\n"); while((i=getchar())!=27){ switch(i){ case '1' : for( j=1 ; 1*j < 50 ; j++ ){ printf("%5d",1*j); if (j%5==0){ printf("\n"); } } break; 接下來就是重複case2到case9先省略不打出來 case '\n': case '\t': case ' ': break; default: printf("Incorrect input\n"); printf("Enter a new number\n"); break; } } } 上面的27是ESC的ASCII Code 我想用這樣來終止程式 , 但沒作用 我沒有辦法寫出如何按下ESC或F1鍵時自動終止程式 請各位幫幫我 , 謝謝 !! } } -- ︵︵ █▔◣ █▔█ █▔▔ █▔█ █▆▉ █ █▔█ █◣█ █▔ █◣︵︵ █ █ █▁◤ █▁▁ █▁█ ▉▉▉ █ █▁█ █◥█ █ █ 夢之大地 逼逼ㄟ四 █▁◤ █ █ █▁▁ █ █ ▉▉▉ █▁ █ █ █ █ █▁◤ ※ Origin: <bbs.ccns.ncku.edu.tw> ◆ From: 61.223.96.108
文章代碼(AID): #17c_Fk00 (Programming)
討論串 (同標題文章)
以下文章回應了本文
2
7
18年前, 01/27
完整討論串 (本文為第 1 之 2 篇):
2
7
18年前, 01/27
18年前, 01/27
文章代碼(AID): #17c_Fk00 (Programming)