C's skip()
(高顯忠, sjgau4311@gmail.com, 2012-03-21 07:12)
1樓
#include <stdio.h>
#include <stdlib.h>
// ----------------------------------------------
// skip( i);
void skip(int no)
{
int i;
// limits no in 1 .. 20
if ((no >= 1) && (no <= 20)) {// no is OK
for (i=1;i<=no;i++) {
// printf("i= %d \n", i);
printf("\n");
}
}
else {// no is invalid
// printf("\n !@#$ no= %d \n", no);
printf("\n");
}
}// end of skip()
// ----------------------------------------------
int main(int argc, char *argv[])
{
int i;
skip(-3);
system("PAUSE");
skip(33);
system("PAUSE");
for (i=1;i<=20;i++) {
skip(i);
printf("i= %5d, i*i= %5d, sqrt(i)= %13.9lf \n",
i, i*i, sqrt(i));
system("PAUSE");
}
system("PAUSE");
return 0;
}// end of main()