1、奇数#include stdio.hint main(void){int i;puts(please input an integer.);printf(i = ); scanf(%d, i);while(i 0){if (i % 2)printf(%d , i);i--;}putchar(\n);return 0;} 2、偶数#include s...
1、奇数
#include <stdio.h>
int main(void)
{
int i;
puts("please input an integer.");
printf("i = "); scanf("%d", &i);
while(i > 0)
{
if (i % 2)
printf("%d ", i);
i--;
}
putchar('\n');
return 0;
}
2、偶数
#include <stdio.h>
int main(void)
{
int i;
puts("please input an integer.");
printf("i = "); scanf("%d", &i);
while(i > 0)
{
if (i % 2 == 0)
printf("%d ", i);
i--;
}
putchar('\n');
return 0;
}
3、奇数
#include <stdio.h>
int main(void)
{
int i;
puts("please input an integer.");
printf("i = "); scanf("%d", &i);
for(i; i > 0; i--)
{
if(i % 2)
printf("%d ", i);
}
putchar('\n');
return 0;
}
4、偶数
#include <stdio.h>
int main(void)
{
int i;
puts("please input an integer.");
printf("i = "); scanf("%d", &i);
for(i; i > 0; i--)
{
if(i % 2 == 0)
printf("%d ", i);
}
putchar('\n');
return 0;
}
沃梦达教程
本文标题为:c语言中输出递减的偶数或者奇数
猜你喜欢
- C语言手把手带你掌握带头双向循环链表 2023-04-03
- Qt计时器使用方法详解 2023-05-30
- C语言详解float类型在内存中的存储方式 2023-03-27
- C语言qsort()函数的使用方法详解 2023-04-26
- C++ 数据结构超详细讲解顺序表 2023-03-25
- 详解C语言中sizeof如何在自定义函数中正常工作 2023-04-09
- ubuntu下C/C++获取剩余内存 2023-09-18
- Easyx实现扫雷游戏 2023-02-06
- 我应该为我的项目使用相对包含路径,还是将包含目录放在包含路径上? 2022-10-30
- c++ const 成员函数,返回一个 const 指针.但是返回的指针是什么类型的 const? 2022-10-11
