- #include<iostream>
- #include<cstdlib>
- using namespace std;
- int cal(int,int);
- int cal(int,int,int);
- int main()
- {
- int x,y,z;
- cout<<"請輸入依序三個數: ";
- cin>>x>>y>>z;
- cout<<"前兩個數相加"<<cal(x,y)<<endl;
- cout<<"三個數相加"<<cal(x,y,z)<<endl;
- system("pause");
- return 0;
- }
- int cal(int x, int y)
- {
- return x+y;
- }
- int cal(int x, int y, int z)
- {
- return x+y+z;
- }
複製代碼 |