看板Programming
标 题C语言问题
发信站梦之大地 (Sat Jan 26 00:33:56 2008)
转信站ptt!ctu-reader!ctu-gate!news.nctu!news2!ccnews.ncku!Dream
请问高手们
题目如下:
输入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