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

TOP

返回列表