gpt4 book ai didi

c - 使用过多内存的运行时错误?

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

#include <stdio.h>

int main()
{
int X = 200;
float Y = 1500;
printf("Enter your initial Balance and the Amount to be Withdrawn. Note the Values should lie between 0 and 2000");
scanf("%d", "%e", &X, &Y);
if ((0 < X < 2000) && (0 < Y < 2000)) {
if ((X < Y) && (X % 5 == 0)) {
Y = Y - X;
Y = Y - 0.5;
} else {
printf("%f", Y);
}
printf("%f", Y);
} else {
printf("The Input is Wrong");
}
return 0;
}

代码基本上要求一些数字 X。从 Y 中减去它,并从 Y 中减去额外的数量 0.5。我们必须给出 Y。该代码给出运行时错误,这可能是由于使用的内存多于允许使用的内存。任何人都可以提供有关如何减少内存使用量或查看程序是否有错误的提示吗?

最佳答案

     scanf("%d,%e", &X, &Y);

关于c - 使用过多内存的运行时错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10823886/

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