求助:帮忙编一个值五分的小程序

满街大聪明 2007-05-19 11:15:34
从键盘输入三个整数a,b,c,按照由小到大的顺序输出。
谢谢了
...全文
263 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
wangyu19870217 2007-05-20
  • 打赏
  • 举报
回复
main()
{
int a,b,c,t;
scanf("%d%d%d",&a,&b,&c);
if(a>b) t=a,a=b,b=t;
if(b>c) t=b,b=c,c=t;
if(a>b) t=a,a=b,b=t;
printf("%d %d %d",a,b,c);
}
guderian1023 2007-05-20
  • 打赏
  • 举报
回复
#include <iostream>
using namespace std;
int main()
{
int a,b,c,min,max,mid;
cin>>a>>b>>c;
if(a<=b)
{
min = a;
max = b;
}
else
{
min = b;
max = a;
}
if(c>=min)
{
if(c>=max)
{
mid = max;
max = c;
}
else
mid = c;
}
else
{
mid = min;
min = c;
}
cout<<min<<" "<<mid<<" "<<max<<endl;
return 0;
}
HWX_C 2007-05-20
  • 打赏
  • 举报
回复
# include <iostream.h>

void swap(int &x,int &y,int &z)
{
int temp;
if(x>y)
{
temp=x;x=y;y=temp;
}
if(y>z)
{
temp=y;y=z;z=temp;
}
if(x>y)
{
temp=x;x=y;y=temp;
}

}

void main()
{
int a, b, c;
cin >>a >>b >>c;
swap(a, b, c);
cout <<a <<b <<c;
}

vc6.0下调试编译运行通过。
满街大聪明 2007-05-20
  • 打赏
  • 举报
回复
谢谢各位
julycy 2007-05-20
  • 打赏
  • 举报
回复
这个,课本上不是有吗?
wanghao2979 2007-05-20
  • 打赏
  • 举报
回复
#include <iostraem>
using namespace std;
int main()
{
int a,b,c;
cout<<"enter a as a number:";
cin>>a;
cout<<"enter b as a number:";
cin>>b;
cout<<"enter c as a number:";
cin>>c;
cout<<"the max is :";
cout<<(a>b?(a>c?a:c):(b>c?b:c));
system("pause");
return 0;
}
没有测试,不知道能不能过
bargio_susie 2007-05-20
  • 打赏
  • 举报
回复
max = a;
if ( b > max )
max = b;
if( c > max )
max = c;
dxh1014 2007-05-20
  • 打赏
  • 举报
回复
#include <iostream.h>
float max(float x,float y)
{float z;

if(x>=y) z=x;else z=y;
return z;
}
int main()
{
float i,j,k;
float temp;
cout<<"Input 3 numbers please: ";
cin>>i>>j>>k;
temp=max(i,j);
temp=max(temp,k);
cout<<"Temp maximum number is"<<temp<<"\n";
return 0;
}

33,317

社区成员

发帖
与我相关
我的任务
社区描述
C/C++ 新手乐园
社区管理员
  • 新手乐园社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧