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