gpt4 book ai didi

c - 为什么我的输出数字不返回输入的输入?

转载 作者:太空宇宙 更新时间:2023-11-04 02:00:05 25 4
gpt4 key购买 nike

我意识到当时我的逻辑陈述不正确,但我对与我的输入不匹配的数字感到沮丧。这些数字通常以大整数形式出现(例如 4128168,对于输入的整数,它们永远不会相同)。我是一般编程的新手,找不到这个错误的答案。感谢您的帮助!

int num1;
int num2;
int num3;
int largest;
int second;

printf("Enter three numbers and I'll identify the largest and second largest.\n");
scanf_s("%d%d", &num1, &num2);
(largest = num1);
(second = 0);

if (num2 > largest)
(largest = num2);
else (num2 > second);
(second = num2);

scanf_s("%d", &num3);
(second = num2);
(largest = num3);

if (num3 > largest)
(largest = num3);
else (second = num3);

printf("The largest number is %d\n", &largest);
printf("The second largest number is %d\n", &second);

return 0;

}

最佳答案

printf("The largest number is %d\n", &largest);
printf("The second largest number is %d\n", &second);

您正在打印地址,打印值:

printf("The largest number is %d\n", largest);
printf("The second largest number is %d\n", second);

关于c - 为什么我的输出数字不返回输入的输入?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28388077/

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