主题:关于比较大小内存出错问题~~
我初学c,正在看谭浩强的c程序设计,做题的时候遇到个问题,比较三个数大小,思路好想,两两比较即可。可编译,可运行,可是,输入数据却出错,提示应用程序错误,提示““0x004020a8”指令引用的“0xccccccc”内存。该内存不能为“written。””,这是什么原因?我代码写错了?不太可能吧,我贴上来大家检查一下吧。
#include<stdio.h>
int main()
{
int a,b,c,d;
printf("please put in three numbers:");
scanf("%d%d%d",a,b,c);
if(a>b)d=a;
else d=b;
if(d>c)d=d;
else d=c;
return 0;
}
还有一种:
#include<stdio.h>
int main()
{
int a,b,c,d;
int max(int x,int y,int z);
printf("please put in three numbers:");
scanf("%d%d%d",a,b,c);
d=max(a,b,c0:
prinef("The bigest is %d\n",d);
return 0;
}
int max(int x,int y,int z)
{
int k;
if(x>y)k=x;
else k=y;
if(k>z)k=k;
else k=z;
return(k);
)
两种都试了,都是那个错误,求解释~~难道溢出了?。。。。求高手解答~
#include<stdio.h>
int main()
{
int a,b,c,d;
printf("please put in three numbers:");
scanf("%d%d%d",a,b,c);
if(a>b)d=a;
else d=b;
if(d>c)d=d;
else d=c;
return 0;
}
还有一种:
#include<stdio.h>
int main()
{
int a,b,c,d;
int max(int x,int y,int z);
printf("please put in three numbers:");
scanf("%d%d%d",a,b,c);
d=max(a,b,c0:
prinef("The bigest is %d\n",d);
return 0;
}
int max(int x,int y,int z)
{
int k;
if(x>y)k=x;
else k=y;
if(k>z)k=k;
else k=z;
return(k);
)
两种都试了,都是那个错误,求解释~~难道溢出了?。。。。求高手解答~