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

TOP

返回列表