方法一:用for
#include <stdio.h>
int main()
{
int i = 1;
int p = 0;
for (i = 1; i <= 100; i++)
{
p=i % 2 ;
if (p == 1)
printf("%d ", i);
}
return 0;
}
方法二:用while
#include <stdio.h>
int main()
{
int i = 1;
while (i <= 100)
{
if (i% 2 == 1)
printf("%d ", i);
i++;
}
return 0;
}
#include <stdio.h>
int main()
{
int i = 1;
while (i <= 100)
{
printf("%d ", i);
i += 2;
}
return 0;
}
标签:输出,include,奇数,int,while,100,main,方法
From: https://blog.51cto.com/u_16202211/7068435