主题:[讨论]求证一道编程题的解是否正确
题目:修改下面程序段
#define MAXINT 100
int Calculate(int apple,int orange)
{int peach,lemon;
peach =0; leamon =0; if(apple<orange){
peach =orange;}[color=FF0000]else if(orange <= apple){
peach =apple;}else{peach =MAXINT;lemon=MAXINT;
}if(lemon!=MAXINT){return(peach);}}[/color]
出自Kruse的《数据结构与程序设计—c语言(第二版)》练习(2)a
本人修改如下
#defined MAXINT 100
int Calulate(int apple,int orange)
{
int peach=0,lemon=0;
if (apple < orange) peach =orange;
else peach =apple;
return (peach)
}
我这样改是否正确,包括格式和算法。
希望大家能给指正,并说明道理。谢谢
#define MAXINT 100
int Calculate(int apple,int orange)
{int peach,lemon;
peach =0; leamon =0; if(apple<orange){
peach =orange;}[color=FF0000]else if(orange <= apple){
peach =apple;}else{peach =MAXINT;lemon=MAXINT;
}if(lemon!=MAXINT){return(peach);}}[/color]
出自Kruse的《数据结构与程序设计—c语言(第二版)》练习(2)a
本人修改如下
#defined MAXINT 100
int Calulate(int apple,int orange)
{
int peach=0,lemon=0;
if (apple < orange) peach =orange;
else peach =apple;
return (peach)
}
我这样改是否正确,包括格式和算法。
希望大家能给指正,并说明道理。谢谢