#include <stdio.h>
int main()
{
long int i;
int count=0;
for(i=1000; i<9999; i++)
if(!((i*10+6)%3))
count++;
printf("count=%d\n",count);
return 0;
}
[root@localhost 18]# ls
5number 5number.c
[root@localhost 18]# ./5number
int main()
{
long int i;
int count=0;
for(i=1000; i<9999; i++)
if(!((i*10+6)%3))
count++;
printf("count=%d\n",count);
return 0;
}
~
[root@localhost 18]# ls
5number.c
[root@localhost 18]# gcc 5number.c -o 5number[root@localhost 18]# ls
5number 5number.c
[root@localhost 18]# ./5number
count=2999
比较简单,仅仅一个for循环就可以解决问题。