標題:
兩數對調
[打印本頁]
作者:
tonyh
時間:
2015-7-24 19:53
標題:
兩數對調
本帖最後由 tonyh 於 2015-7-24 20:06 編輯
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int x,y,tmp;
cout<<"請輸入x的值: ";
cin>>x;
cout<<"請輸入y的值: ";
cin>>y;
cout<<"對調前: x="<<x<<" y="<<y<<endl;
tmp=x;
x=y;
y=tmp;
cout<<"對調後: x="<<x<<" y="<<y<<endl;
system("pause");
return 0;
}
複製代碼
作者:
沈子耕
時間:
2015-7-24 20:14
#include<iostream>
#include<cstdlib>
using namespace std;
int main(){
int x, y, tmp;
cout<<"請輸入x: ";
cin>>x;
cout<<"請輸入y: ";
cin>>y;
cout<<endl<<"對調前 x="<<x<<" y="<<y<<endl;
tmp=x;
x=y;
y=tmp;
cout<<endl<<"對調後 x="<<x<<" y="<<y<<endl;
system("pause");
return 0;
}
複製代碼
作者:
陳思惟
時間:
2015-7-24 20:18
#include <iostream>
#include <cstdlib>
using namespace std;
int main()
{
int x,y,tmp;
cout<<"x:";
cin>>x;
cout<<"y:";
cin>>y;
cout<<"前: x:"<<x<<" y:"<<y<<endl;
tmp=x;
x=y;
y=tmp;
cout<<"後: x:"<<x<<" y:"<<y;
system("pause");
return 0;
}
複製代碼
作者:
曾挺桂
時間:
2015-7-24 20:18
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int x,y,tmp;
cout<<"請輸入x的值: ";
cin>>x;
cout<<"請輸入y的值: ";
cin>>y;
cout<<"對調前: x="<<x<<" y="<<y<<endl;
tmp=x;
x=y;
y=tmp;
cout<<"對調後: x="<<x<<" y="<<y<<endl;
system("pause");
return 0;
}
複製代碼
作者:
林侑成
時間:
2015-7-24 20:43
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int x,y,tmp;
cout<<"請輸入x的值: ";
cin>>x;
cout<<"請輸入y的值: ";
cin>>y;
cout<<"對調前: x="<<x<<" y="<<y<<endl;
tmp=x;
x=y;
y=tmp;
cout<<"對調後: x="<<x<<" y="<<y<<endl;
system("pause");
return 0;
}
複製代碼
歡迎光臨 種子論壇 | 高雄市資訊培育協會學員討論區 (http://istak.org.tw/seed/)
Powered by Discuz! 7.2