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