// 限制 no 在 1 到 20 中間
if ((no >= 1) && (no <= 20)) {// OK
for (i=1;i<=no;i++) {
printf("\n");
}
}
else {// no 不在 1 到 20 中間
printf("\n");
}// end if
}// end of skip()
// ----------------------------------------------
// pause();
void pause(void)
{
int ch1;
// remove type ahead
while (kbhit()) {
ch1= getch();
}// end while
printf("\n Press [Esc] for program stop! other key for continue ...");
do {
// wait for keyPressed
} while(!kbhit());
printf("\n");
ch1= getch();
if (ch1 == 0x1b) {// [Esc] key be pressed
exit(1);// exit the program
}
// remove extra key
while (kbhit()) {
ch1= getch();
}
}// end of pause()
// ----------------------------------------------
int main(int argc, char *argv[])
{
int i;
for (i=1;i<=20;i++) {
skip(i);
printf("i= %5d, i*i= %5d, sqrt(i)= %10.6lf \n", i, i*i, sqrt(i));
pause();
}// end for
system("pause");
return EXIT_SUCCESS;
}// end of main()