Untitled
#include <iostream> using namespace std; int main() { int fib1 = 0, fib2 = 1, fib3, i, n; cin >> n; if (n != 0) { for (i = 0; i < n - 1; i++) { fib3 = fib2; fib2 = fib1 + fib2; fib1 = fib3; } cout << fib2; } else { cout << 0; } }
#include <iostream> using namespace std; int main() { int fib1 = 0, fib2 = 1, fib3, i, n; cin >> n; if (n != 0) { for (i = 0; i < n - 1; i++) { fib3 = fib2; fib2 = fib1 + fib2; fib1 = fib3; } cout << fib2; } else { cout << 0; } }