C語言問題
請問高手們
題目如下:
輸入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
討論串 (同標題文章)
Programming 近期熱門文章
PTT數位生活區 即時熱門文章