2012年12月7日 星期五

c++之數字大擺在前面


#include<iostream>
#include<cstdlib>
using namespace std;
main()
{
cout<<"請輸入兩個數字,我會把較大的數字放在前面"<<endl;
int a,b,c;
cin>>a>>b;
if(b>a)
{
c=b;
b=a;
a=c;
cout<<"magic!"<<a<<"  "<<b<<endl;
}
else if(a>b)
{
cout<<"magic!"<<a<<"  "<<b<<endl;
}
else
{
cout<<"magic!"<<a<<"="<<b<<endl;
}
}

沒有留言:

張貼留言