啊哈磊_编程从这里起步
标题:
判断这个数是否是单数是输出yes不是输出no
[打印本页]
作者:
行田然
时间:
2020-3-19 12:30
标题:
判断这个数是否是单数是输出yes不是输出no
#include <stdio.h>
#include <stdlib.h>
int main()
{
int a;
scanf("%d",&a);
if (a==1,2,3,4,5,6,7,8,9)
{
printf("yes");
}
else
{
printf("no");
}
return 0;
}
复制代码
作者:
The Death
时间:
2020-3-19 13:27
本帖最后由 The Death 于 2020-3-19 13:36 编辑
第7行那个逗号没用的,|| 才表示或
还有,最好加一个while循环,可以重复用
作者:
The Death
时间:
2020-3-19 13:34
本帖最后由 The Death 于 2020-3-19 14:11 编辑
修改后代码如下
#include <stdio.h>
#include <stdlib.h>
int main()
{
int a;
while(1)
{
scanf("%d",&a);
if (a==1||a==2||a==3||a==4||a==5||a==6||a==7||a==8||a==9||a==0)
{
printf("yes");
}
else
{
printf("no");
}
}
return 0;
}
作者:
嘟嘟编程
时间:
2020-3-21 14:01
本帖最后由 嘟嘟编程 于 2020-3-21 14:06 编辑
话不多说,上代码:
#include<stdio.h>
int main()
{
int n;
scanf("%d",&n);
if(n%2!=0)
printf("Yes");
else
printf("No");
return 0;
}
作者:
任涵予
时间:
2020-3-22 16:08
逗号是没用的,需要用逻辑或(||)
欢迎光临 啊哈磊_编程从这里起步 (https://bbs.codeaha.com/)
Powered by Discuz! X3.2