如何从数字区间中查找具有对称二进制表示形式的数字(回文)[关闭]

问题描述 投票:-3回答:1

请帮助。]

int main(){
int a,b; /*a is the lowest number, b is the greatest number*/
char ch;

printf("Interval:/n");
scanf("%c %d %d", &ch,&a,&b);


if((scanf("%c %d %d", &ch,&a,&b))!= 3 || a<0 || b<0 || b<a || ch != 'k' || ch != 'd') {

printf("Wrong interval/n");
return 1;
}
return 0;
}

1)我的if语句正确吗?如何做到这一点,以便我在一行中输入“ l 30 100”,按回车键将停止输入,并且不会将我发送到新行?

c
1个回答
0
投票

以下建议的代码:

© www.soinside.com 2019 - 2024. All rights reserved.