注册 登录
编程论坛 C++教室

来帮帮忙,编个程序!谢谢了

小然然 发布于 2010-03-21 16:50, 701 次点击
输入三个整数,并输出他们之中的最大值。
6 回复
#2
雪色朝阳2010-03-21 17:21
#include<stdio.h>
main()
{
int a,b,c,max;
printf("请输入三个数:\n");
scanf("%d,%d,%d",&a,&b,&c);
   max=a;
 if(b>a&&b>c)
     max=b;
 else if(c>b&&c>a)
     max=c;
 printf("最大值是:%d\n",max);
}
#3
llooppzhang2010-03-21 18:20
#include<stdio.h>
 main()
{
int a,b,c ,max;
printf("输入三数\n");
scanf("%d,%d,%d",&a,&b,&c);
int t;
max=(t=(a>b? a:b)>c t:c);
printf("max=%d",max);
}
没调试。不知道行不行
#4
hahayezhe2010-03-21 19:13
max=(t=(a>b? a:b)>c t:c);

要这么写max=(t=a>b? a:b)>c?t:c;
#5
apull2010-03-22 00:40
?:的嵌套。。
#6
本大爷死了2010-03-23 13:00
#include <iostream.h>
int main()
{
    int a,b,max=0;
    cout<<"enter three integers:"<<endl;
    cin>>a,b,max;
    if(a>b)
      { if(a>max)    max=a;   }
    else
      {  if(b>max)   max=b;   }
    cout<<"the max one is :"<<max<<endl;
    return 0;
}
#7
guchao20092010-03-26 13:03
建议用函数写程序
#include<iostream>
using namespace std;

double max(double x,double y)
{
   return (x>y?x:y);
}

int main()
{
    double a,b,c;
    double mid1,mid2;
     cin>>a>>b>>c;
     mid1=max(a,b);
     mid2=max(mid1,c);
     cout<<"最大值是"<<mid2<<endl;
     return 0;
}
1