返回列表 發帖
  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int cal(int a,int b)
  5. {
  6.     return a+b;
  7. }
  8. int cal(int a,int b,int c)
  9. {
  10.     return a+b+c;
  11. }
  12. int main()
  13. {
  14.     int a, b, c;
  15.     cout<<"請依序輸入三個數字: ";
  16.     cin>>a>>b>>c;
  17.     cout<<"前兩數相加: "<<cal(a,b)<<endl;
  18.     cout<<"三個數相加: "<<cal(a,b,c)<<endl;   
  19.     system("pause");   
  20.     return 0;
  21. }
複製代碼
Allen

TOP

返回列表