要练习算法就来http:///!!有挑战哦!!
#include <stdio.h>
void main()
{
int num1,num2,num3;
clrscr();
printf("\n one:");
scanf("%d",&num1);
printf("\n two:");
scanf("%d",&num2);
printf("\n three:");
scanf("%d",&num3);
if((num1>num2)&&(num2>num3))
printf("\n%d",num1);
if((num2>num1)&&(num2>num3))
printf("\n%d",num2);
if((num3>num1)&&(num3>num2))
printf("\n%d",num3);
} 上面是按你的思路改的,调试过了!
这是我用的两种算法,有一点点不同,请参考:
方法一:
#include <stdio.h>
void main()
{
int num1,num2,num3,max;
printf("\n num1:");
scanf("%d",&num1);
printf("\n num2:");
scanf("%d",&num2);
printf("\n num3:");
scanf("%d",&num3);
if(num2>num1)
max=num2;
else
max=num1;
if(num3>max)
max=num3;
printf("The max number is %d",max);
}
方法二:
#include <stdio.h>
void main()
{
int num1,num2,num3,max;
printf("\n num1:");
scanf("%d",&num1);
printf("\n num2:");
scanf("%d",&num2);
printf("\n num3:");
scanf("%d",&num3);
max=num1;
if(num2>max)
max=num2;
if(num3>max)
max=num3;
printf("The max number is %d",max);
}