----------------解决方案--------------------------------------------------------
#include <stdio.h>
void main()
{
int num1,num2,num3;
printf("\n 输入第一个数:");
scanf("%d",&num1);
printf("\n 输入第二个数:");
scanf("%d",&num2);
printf("\n 输入第三个数:");
scanf("%d",&num3);
if((num1>num2)&&(num2>num3));
printf("\n %d\n",num1);
else if((num2>num1)&&(num2>num3));
printf("\n %d\n",num2);
else
printf("\n %d\n",num3);
}
应该是这样的吧。。。如果有错各位也更正下,谢谢
----------------解决方案--------------------------------------------------------
#include <stdio.h>
main()
{
int k=0,i,j,a[3];
printf("\nplease input 3 numbers ");
for(j=0;j<3;j++)
scanf("%d",&a[j]);
for(i=1;i<3;i++)
{
if(a[i]>=a[k])
k=i;
}
printf("%d",a[k]);
}
你那个算法太庞大了,改成这个冒泡法更简单些。
----------------解决方案--------------------------------------------------------
#include <stdio.h>
void main()
{
int num1,num2,num3;
printf("\n 输入第一个数:");
scanf("%d",&num1);
printf("\n 输入第二个数:");
scanf("%d",&num2);
printf("\n 输入第三个数:");
scanf("%d",&num3);
if((num1>num2)&&(num2>num3)); //改成1,“;”去掉
printf("\n %d\n",num1);
else if((num2>num1)&&(num2>num3));//“;”去掉
printf("\n %d\n",num2);
else printf("\n %d\n",num3);
}
----------------解决方案--------------------------------------------------------
#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);
}
----------------解决方案--------------------------------------------------------
看来我还嫩啊。。。呵呵。。有的地方还是会粗心大意啊。。
----------------解决方案--------------------------------------------------------
int main()
{
int a,b,c,max;
printf("input three integers:");
scanf("%d%d%d",&a,&b,&c);
max=a>=b?(a>=c?a:c):(b>=c?b:c);
printf("The maximum integer is %d.\n",max);
return 0;
}
这种算法好
----------------解决方案--------------------------------------------------------
顶一下楼主的ID
太强大了
----------------解决方案--------------------------------------------------------
我彻底看晕了~。。。我的思路太乱了~
----------------解决方案--------------------------------------------------------