標題:
五則運算
[打印本頁]
作者:
游東祥
時間:
2014-1-22 11:41
標題:
五則運算
[attach]813[/attach]
1. 在程式內宣告兩個整數變數x與y,並自訂兩個數字存放於x與y。
2. 輸出 x 與 y 以下五種結果: 加法、減法、乘法、除法、取餘數
作者:
林宇翔
時間:
2014-1-22 11:55
#include <iostream>
#include <cstdlib>
using namespace std;
int main()
{
int x =21;
int y =5;
cout << "當 x = " << x << ", y = " << y << " 時 "<<endl;
cout << " x + y = "<< x+y << endl;
cout << " x - y = "<< x-y << endl;
cout << " x * y = "<< x*y << endl;
cout << " x / y = "<< x/y << endl;
cout << " x % y = "<< x%y << endl;
system("pause");
return 0;
}
複製代碼
作者:
陳婉平
時間:
2014-1-22 11:56
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int x = 29;
int y = 2;
cout << "當 x = " << x << ", y = " << y <<"時:" <<endl;
cout << "x + y = " << x+y << endl;
cout << "x - y = " << x-y << endl;
cout << "x * y = " << x*y << endl;
cout << "x / y = " << x/y << endl;
cout << "x % y = " << x%y << endl;
system("pause");
return 0;
}
複製代碼
作者:
劉得恩
時間:
2014-1-22 11:58
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int x=21,y=5;
cout<<"當 x = "<< x <<", y=" << y <<" 時:"<<endl;
cout <<"x + y = " <<x+y <<endl<< "x - y= "<<x-y <<endl
<<"x * y = " <<x*y <<endl <<" x / y= " <<x/y <<endl
<<"x % y = "<<x%y<<endl;
system("pause");
return 0;
}
複製代碼
作者:
陳均
時間:
2014-1-22 11:58
#include<iostream>
#include<cstdlib>
using namespace std;
int main ()
{
int x = 21;
int y = 5;
cout <<"當 x = "<< x << " ,y = "<<y<<"時"<<endl;
cout <<" x + y = " << x+y <<endl;
cout <<" x - y = " << x-y <<endl;
cout <<" x * y = " << x*y <<endl;
cout <<" x / y = " << x/y <<endl;
cout <<" x % y = " << x%y <<endl;
system("pause");
return 0;
}
複製代碼
作者:
李允軒
時間:
2014-1-22 11:58
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int x = 21;
int y = 5;
cout<<"當 x ="<<x<<". y ="<<y<<"時"<<endl;
cout<<"x + y ="<<x+y<<endl;
cout<<"x - y ="<<x-y<<endl;
cout<<"x * y ="<<x*y<<endl;
cout<<"x / y ="<<x/y<<endl;
cout<<"x % y ="<<x%y<<endl;
system("pause");
return 0;
}
複製代碼
作者:
蔡維庭
時間:
2014-1-22 11:58
#include <iostream>
#include <cstdlib>
using namespace std;
int main()
{
int x = 21;
int y = 5;
cout << "當 x =" << x << ", y = " << y << "時" << endl;
cout << "x + y =" << x+y << endl;
cout << "x - y =" << x-y << endl;
cout << "x * y =" << x*y << endl;
cout << "x / y =" << x/y << endl;
cout << "x % y =" << x%y << endl;
cout << "這就是x和y的加減乘除和餘數的運算~" << endl;
system("pause");
return 0;
}
複製代碼
作者:
任冠宇
時間:
2014-1-22 11:59
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int x=5;
int y=8;
cout<<"當 x= "<<x<<", y= "<<y<<"時:"<<endl;
cout<<"x + y="<<x+y<<endl;
cout<<"x - y="<<x-y<<endl;
cout<<"x * y="<<x*y<<endl;
cout<<"x / y="<<x/y<<endl;
cout<<"x % y="<<x%y<<endl;
system("pause");
return 0;
}
複製代碼
作者:
郭品君
時間:
2014-1-22 11:59
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int x=34;
int y=35;
cout<<"當X="<<x<<"Y"<<y<<"時:"<< endl;
cout<<"x +y="<<x+y<<endl;
cout<<"x -y="<<x-y<<endl;
cout<<"x *y="<<x*y<<endl;
cout<<"x /y="<<x/y<<endl;
system("pause");
return 0;
}
複製代碼
作者:
黃詠軒
時間:
2014-1-22 11:59
本帖最後由 黃詠軒 於 2014-1-22 12:01 編輯
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int x = 21,y = 5;
cout <<"當 x = "<< x << ",y =" << y << "時:" << endl
<<"x+y=" <<x+y <<endl <<"x-y=" <<x-y <<endl
<<"x*y=" <<x*y <<endl <<"x/y=" <<x/y <<endl
<<"x%y=" <<x%y <<endl;
system("pause");
return 0;
}
複製代碼
作者:
朱俐蒨
時間:
2014-1-22 12:01
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int x=21;
int y=5;
cout<<"當x="<< x<<" 當y="<<y<<"時:" <<endl;
cout<< "x + y ="<<x+y<<endl;
cout<< "x - y ="<<x-y<<endl;
cout<< "x * y ="<<x*y<<endl;
cout<< "x / y ="<<x/y<<endl;
cout<< "x % y ="<<x%y<<endl;
system("pause");
return 0;
}
複製代碼
作者:
黃國清
時間:
2014-1-22 12:01
#include <iostream>
#include <cstdlib>
using namespace std;
int main()
{
int x=30678;
int y=87603;
cout<<"當 X = "<<x<<", y = "<<y<<"時:"<<endl;
cout<<"x + y ="<<x+y<<endl;
cout<<"x - y ="<<x-y<<endl;
cout<<"x * y ="<<x*y<<endl;
cout<<"x / y ="<<x/y<<endl;
cout<<"x % y ="<<x%y<<endl;
system("pause");
return 0;
}
複製代碼
作者:
劉芝均
時間:
2014-1-22 12:06
#include <iostream>
#include<cstdlib>
using namespace std;
int main()
{
int x =21;
int y =5;
cout <<"當 x ="<< x <<" ,y ="<< y << "時"<< endl;
cout<<"x+y="<<x+y <<endl;
cout<<"x-y="<<x-y<<endl;
cout<<"x*y="<<x*y <<endl;
cout<<"x/y="<<x/y <<endl;
cout<<"x%y="<<x%y <<endl;
system("pause");
return 0;
} [code]
複製代碼
[/code]
作者:
劉怡修
時間:
2014-1-23 10:09
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int x = 21;
int y= 5;
cout << "當 x = "<<x<< ", y = "<<"時: endl
cout << " x+y= " << x+y <<endl;
cout << " x-y= " << x-y <<endl;
cout << " x*y= " << x*y <<endl;
cout << " x|y= " << x|y <<endl;
cout << " x%y= " << x%y <<endl;
system("pause");
return 0;
複製代碼
作者:
劉凱平
時間:
2014-1-23 10:10
#include <iostream>
using namespace std;
int main()
{
int x =21;
int y =5;
cout<<"當 x = " <<x<< ",y = "<<"時:"<< endl;
cout << " x + y ="<< x+y <<endl;
cout << " x - y ="<< x-y <<endl;
cout << " x * y ="<< x*y <<endl;
cout << " x / y ="<< x/y <<endl;
cout << " x % y ="<< x%y <<endl;
system("pause");
return 0;
}
複製代碼
複製代碼
歡迎光臨 種子論壇 | 高雄市資訊培育協會學員討論區 (http://seed.istak.org.tw/)
Powered by Discuz! 7.2