(1)利用for循环和if语句打印
#include<stdio.h>
int main()
{
int i=0;
int count=0;
for(i=1;i<=100;i++)
{
if(i%2==1)
int main()
{
int i=0;
int count=0;
for(i=1;i<=100;i++)
{
if(i%2==1)
printf("%d ",i);
count++;
}
printf("\n");
printf("count=%d",count);
return 0;
}
count++;
}
printf("\n");
printf("count=%d",count);
return 0;
}
(2)直接for循环打印
#include<stdio.h>int main()
{
int i=0;
int count=0;
for(i=1;i<=100;i+=2)
printf("%d ",i);
return 0;
printf("count=%d\n",count);
}