热门

最新

红包

立Flag

投票

同城

我的

发布
zk504390402
一只蛙~( ̄▽ ̄~)~
4 年前
truezk504390402

#include<iostream>//compare the amount of five nums 1.0
using namespace std;
int main()
{
int a,b,c,d,e;
cout<<"plesase input 5 num"<<"systerm will tell you which one is the bigest"<<endl;
cin>>a>>b>>c>>d>>e;//相当于scanf
int arr[5]={a,b,c,d,e};
int temp=arr[0];
int i=1;
while (i<20)
{
i++;//i is used to limit the times of while
if(arr[0]>arr[1]){
temp=arr[0];
arr[0]=arr[1];
arr[1]=temp;
}
if(arr[1]>arr[2]){
temp=arr[1];
arr[1]=arr[2];
arr[2]=temp;
}
if(arr[2]>arr[3]){
temp=arr[2];
arr[2]=arr[3];
arr[3]=temp;
}
if(arr[3]>arr[4]){
temp=arr[3];
arr[3]=arr[4];
arr[4]=temp;
}


}
cout<<arr[0]<<"<"<<arr[1]<<"<"<<arr[2]<<"<"<<arr[3]<<"<"<<arr[4];
return 0;
}

CSDN App 扫码分享
分享
评论
点赞
打赏
  • 复制链接
  • 举报
下一条:
https://zhuanlan.zhihu.com/p/114502325?from_voters_page=trueslot的用法
立即登录