Test FromNum~TermNum output can divide into divisor

来源:互联网 发布:windows核心编程 源码 编辑:程序博客网 时间:2024/05/21 17:00

Need to do as follows

1>  every line have lineNum

2> show the number that can't divide into divisor; if the number can't divide into the divisor, then replace it by <SPACE>

continue_test.c

 #include<stdio.h>   #define fromNum   1  #define termNum   30  #deine divisor   2  #define lineNum   5   int main(int argc, char *agrv[]){          int number, flag;          for(number = fromNum, flag = 0; number <= termNum; flag++, number++)          {                  if(!(flag%lineNum) && flag)                  {                          printf("\n");                  }                  if(!(number%divisor))                  {                          printf("    ");                          continue;                  }                  else                          printf(" %02d ", number);          }          printf("\n");}      
Makefile

 make:          gcc -o swit_test swit_test.c clean:         rm -rf swit_test
The Result as follows

[root@localhost switch_test]# ./swit_test  01      03      05      07      09      11      13      15      17      19      21      23      25      27      29  

PS. this program can be extension from the define



原创粉丝点击