void main()
{
int a,b,c,d;
printf("please input the first number: ");
scanf("%d",&a);
printf("\nplease input the second number: ");
scanf("%ld",&b);
printf("\nplease input the third number: ");
scanf("%ld",&c);
printf("\nplease input the forth number: ");
scanf("%ld",&d);
printf("the number is %d %d %d %d\n",a,b,c,d);
if((a==0)&&(b==0)&&(c==0)&&(d==0))
{
exit(-1);
}
else if(((a<MIN_DATA)||(a>MAX_DATA))||((a<MIN_DATA)||(a>MAX_DATA))
||((a<MIN_DATA)||(a>MAX_DATA))||((a<MIN_DATA)||(a>MAX_DATA)))
{
printf("ERROR!!!\n");
}
else
{
int m = (a-b)>0?a:b;
int n = (c-d)>0?c:d;
int val = (m-n)>0?m:n;
printf("the max value is %d\n",val);
}
}
哈哈,看懂了```
改了一下代码`
/* Note:Your choice is C IDE */
#include "stdio.h"
#include <stdlib.h>
#include <conio.h>
main()
{
int number,i;
double a=1.0e6;
int max=-3254;
aa:
for(i=1;i<5;i++)
{
printf("please enter number %d:",i);
scanf("%d",&number);
if(number>a||number<-a) //设定范围
{
printf("Input is out of range.\n");
goto aa; //跳回去,大家都说用GOTO不好,呵呵``可能我还没领悟吧~
}
if(number>max)//判断最大值
max=number;
}
if(max==0)//如果最大值为0,也就是说4个值都为0就结束程序
exit (0);
printf("max number is:%d",max);
}
这样,我没判断如果4个0就结束程序,我判断最大值为0就结束,呵呵`效果一样的`
小弟不才,这是小弟的代码~win2000+Turbo c下编译的`~
#include "stdio.h"
main()
{
int number,i;
double a=1.0e6;
int max=-3254;
aa:
for(i=1;i<5;i++)
{
printf("please enter number %d:",i);
scanf("%d",&number);
if(number>a||number<-a)
{
printf("Input is out of range.\n");
goto aa;
}
if(number>max)
max=number;
}
printf("max number is:%d",max);
}
测试可以实现~不知道楼主满不满意~