gpt4 book ai didi

c - 为什么这个 for 循环会被忽略?

转载 作者:太空宇宙 更新时间:2023-11-04 08:13:04 24 4
gpt4 key购买 nike

<分区>

我不确定我做错了什么但是 for 循环没有初始化
代码立即显示 printfs。它们没有值,因为 for 循环没有激活

#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>
#define PAUSE system("Pause")

main() {
// INITALIZE VARIABLES
int number = 0;
int i = 0;
int odd = 0;
int even = 0;
int totalNum = 0;
int tempNum = 0;
int count;

printf("Enter a number between 2 and 25\n");
scanf("%i", &number);

do{
if (number < 2 || number > 25)
printf("That was an invalid number please try again\n");
scanf("%i", &number);
} while (number < 2 || number > 25);

printf("Enter how many numbers you want to input\n");
scanf("%i", &count);

for (i = 1; i == count; ++i){
printf("input numbers\n");
scanf("%i", &tempNum);
if (tempNum % 2 == 0)
even++;
else
odd++;
totalNum = totalNum + tempNum;
} // END FOR LOOP

// DISPLAY OUTPUT
printf("You entered %i numbers\n", count);
printf("The sum of the %i numbers is %i\n", count, totalNum);
printf("The average of the %i numbers is %i\n", count, totalNum / count);
printf("You entered %i odd numbers and %i even numbers\n", odd, even);

PAUSE;
} // END MAIN

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