#255
Se dă un număr natural n. Să se afişeze în ordine crescătoare, primii n termeni ai şirului lui Fibonacci.
| Problema | Fibonacci | Operații I/O |
tastatură/ecran
|
|---|---|---|---|
| Limita timp | 0.1 secunde | Limita memorie |
Total: 64 MB
/
Stivă 8 MB
|
| Id soluție | #64764793 | Utilizator | |
| Fișier | fibonacci.cpp | Dimensiune | 451 B |
| Data încărcării | 28 Mai 2026, 15:48 | Scor/rezultat | Eroare de compilare |
fibonacci.cpp: In function ‘int main()’: fibonacci.cpp:6:5: error: ‘cin’ was not declared in this scope; did you mean ‘std::cin’? 6 | cin>>n; | ^~~ | std::cin In file included from fibonacci.cpp:1: /usr/include/c++/13/iostream:62:18: note: ‘std::cin’ declared here 62 | extern istream cin; ///< Linked to standard input | ^~~ fibonacci.cpp:7:9: warning: suggest parentheses around assignment used as truth value [-Wparentheses] 7 | if(n=1) | ~^~ fibonacci.cpp:9:9: error: ‘cout’ was not declared in this scope; did you mean ‘std::cout’? 9 | cout<<0; | ^~~~ | std::cout /usr/include/c++/13/iostream:63:18: note: ‘std::cout’ declared here 63 | extern ostream cout; ///< Linked to standard output | ^~~~ fibonacci.cpp:10:13: error: expected ‘}’ before ‘else’ 10 | else | ^~~~ fibonacci.cpp:8:5: note: to match this ‘{’ 8 | { | ^ fibonacci.cpp:11:17: warning: suggest parentheses around assignment used as truth value [-Wparentheses] 11 | if(n=2) | ~^~ fibonacci.cpp:13:13: error: ‘cout’ was not declared in this scope; did you mean ‘std::cout’? 13 | cout<<0<<1; | ^~~~ | std::cout /usr/include/c++/13/iostream:63:18: note: ‘std::cout’ declared here 63 | extern ostream cout; ///< Linked to standard output | ^~~~ fibonacci.cpp:14:17: error: expected ‘}’ before ‘else’ 14 | else | ^~~~ fibonacci.cpp:12:9: note: to match this ‘{’ 12 | { | ^ fibonacci.cpp:19:12: error: ‘cout’ was not declared in this scope; did you mean ‘std::cout’? 19 | cout<<f1<<f2; | ^~~~ | std::cout /usr/include/c++/13/iostream:63:18: note: ‘std::cout’ declared here 63 | extern ostream cout; ///< Linked to standard output | ^~~~ fibonacci.cpp:20:23: error: expected ‘;’ before ‘)’ token 20 | for(i=3;i<n) | ^ | ; fibonacci.cpp: At global scope: fibonacci.cpp:29:5: error: expected declaration before ‘}’ token 29 | } | ^ fibonacci.cpp:30:5: error: expected unqualified-id before ‘return’ 30 | return 0; | ^~~~~~ fibonacci.cpp:31:1: error: expected declaration before ‘}’ token 31 | } | ^
www.pbinfo.ro permite evaluarea a două tipuri de probleme:
Problema Fibonacci face parte din prima categorie. Soluția propusă de tine va fi evaluată astfel:
Suma punctajelor acordate pe testele utilizate pentru verificare este 100. Astfel, soluția ta poate obține cel mult 100 de puncte, caz în care se poate considera corectă.