- #include <cstdlib>
- #include <iostream>
- using namespace std;
- int print(int first_number,int second_number,int times)
- {
- int total=0;
- cout<<first_number<<endl;
- cout<<second_number<<endl;
- for(int i=times;i<=times;i++)
- {
- total=first_number+second_number;
- cout<<total<<endl;
- first_number=second_number;
- second_number=total;
- return total;
- }
- }
- int main()
- {
- int first_number=0;
- int second_number=0;
- int times=0;
- cout<<"請輸入第一個數:";
- cin>>first_number;
- cout<<"請輸入第二個數:";
- cin>>second_number;
- cout<<"請輸入你要的個數:";
- cin>>times;
- cout<<print(first_number,second_number,times)<<endl;
- system("pause");
- return 0;
- }
複製代碼 |