Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<fstream>
- using namespace std;
- int main()
- {
- long long a = 0, b = 1;
- int c;
- cout << "Podaj liczbe wyrazow ciagu fibonacciego" << endl;
- cin >> c;
- ofstream wynik("wynik.txt");
- for (int i = 0; i < c; i++) {
- if (i == 0) wynik << a << endl;
- else if (i == 1) wynik << b << endl;
- else {
- b += a;
- a = b - a;
- wynik << b << endl;
- }
- }
- wynik.close();
- cout << "Wyrazy ciagu zostaly zapisane w pliku wynik.txt" << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement