- #include<iostream>
- #include<cstdlib>
- using namespace std;
- int cal (int,int);
- int cal (int,int,int);
- int main()
- {
- int x,y,z;
- cout<<"依序輸入3個數字";
- cin>>x>>y>>z;
- cout<<"前2數相加"<<cal(x,y)<<endl;
- cout<<"3個數相加"<<cal(x,y,z);
- 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;
- }
複製代碼 |