main()
{
int i,n=0;
for(i=1;i<=200;i++)
if(((i%2==0)&&(i%3!=0))||((i%2!=0)&&(i%3==0)))
n++;
printf("%d",n);
}
小问题有那么麻烦吗?
#include
define N 2000
fun(int N)
{
int i,count;
for (i=0;i<=N;i++)
if ((i%2==0||i%3==0)&&(i%6!=0))
count++;
return count
}
main()
{
printf("%d",fun(N));
}
#include
void main()
{int i,j=0;
int a[30];
for(i=1;i<=200;i++)
{if(i%2==0||i%3==0&&i%2%3!=0)a[j++]=i;}
printf("there are %d numbers\n",j);
printf("the numbers are:\n");
for(i=0;i
}
#include
int main()
{
int i,count2,count3;
count2=0;
count3=0;
for(i=1;i<=200;i++)
{
if((i%2==0)&&(i%3!=0))
count2++;
if((i%3==0)&&(i%2!=0))
count3++;
}
printf("count2=%d count3=%d\n",count2,count3);
return 0;
}
int count=0;
for(int i=1;i<=200;i++)
{
if(i%2==0||i%3==0)
{
if(i%2==0&&i%3!=0)
count++;
if(i%2!=0&&i%3==0)
count++;
}
}
printf("%d",i);