2017년 4월 18일 화요일

세 숫자 정렬

#include <iostream>
using namespace std;
int main() {
 int a, b, c;
 int temp;
 cout<<"Enter three integers : "; cin>>a>>b>>c;

 if(a>b){
  temp = a;
  a = b;
  b = temp;
 }
 if(b>c){
  temp = b;
  b = c;
  c = temp;
 }
 if(a>b){
  temp = a;
  a = b;
  b = temp;
 }

 cout<<a<<" "<<b<<" "<<c<<endl;

 return 0;

}

댓글 없음:

댓글 쓰기