gpt4 book ai didi

c - 为什么我不能得到正确的句子输出?

转载 作者:行者123 更新时间:2023-11-30 20:50:31 25 4
gpt4 key购买 nike

有什么问题吗..我听不懂完整的句子

"even(variable) numbers are even".

#include <stdio.h>
void main()
{
int i = 1, n = 0, even = 0, odd = 0;
do{
printf("Type in a Number-");
scanf("%d", &n);
if(n % 2 == 0)
even = even + 1;
else
odd = odd + 1;
i = i + 1;
}
while(i <= 10);
printf("%d", even "numbers are even.");
printf("%d", odd "numbers are odd.");
}

最佳答案

看来您只需要正确格式化字符串,程序就可以运行:

#include <stdio.h>

int main(void) {
int i = 1, n = 0, even = 0, odd = 0;
do {
printf("Type in a Number-");
scanf("%d", &n);
if (n % 2 == 0)
even = even + 1;
else
odd = odd + 1;
i = i + 1;
} while (i <= 10);
printf("%d numbers are even.", even);
printf("%d numbers are odd.", odd);
return 0;

}

关于c - 为什么我不能得到正确的句子输出?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44618281/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com