#1536
Ecuatii
Să considerăm ecuaţii de gradul I, de forma: expresie_1=expresie_2
. Expresiile specificate sunt constituite dintr-o succesiune de operanzi, între care există semnul +
sau semnul -
(cu semnificaţia binecunoscută de adunare, respectiv scădere). Fiecare operand este fie un număr natural, fie un număr natural urmat de litera x
(litera x
reprezentând necunoscuta), fie doar litera x
(ceea ce este echivalent cu 1x
).
De exemplu: 2x-5+10x+4=20-x
. Observaţi că în ecuaţiile noastre nu apar paranteze şi necunoscuta este întotdeauna desemnată de litera mică x
.
Scrieţi un program care să rezolve ecuaţii de gradul I, în formatul specificat în enunţul problemei.
OJI 2006, Clasa a X-a
Problema | Ecuatii | Operații I/O |
ecuatii.in /ecuatii.out
|
---|---|---|---|
Limita timp | 0.1 secunde | Limita memorie |
Total: 64 MB
/
Stivă 8 MB
|
Id soluție | #54094388 | Utilizator | |
Fișier | ecuatii.cpp | Dimensiune | 2.84 KB |
Data încărcării | 19 Noiembrie 2024, 17:08 | Scor / rezultat | Eroare de compilare |
ecuatii.cpp:6:13: error: variable 'std::ifstream cin' has initializer but incomplete type ifstream cin("ecuatii.in"); ^ ecuatii.cpp:7:14: error: variable 'std::ofstream cout' has initializer but incomplete type ofstream cout("ecuatii.out"); ^ ecuatii.cpp: In function 'void Prelucreaza(char*)': ecuatii.cpp:97:32: error: reference to 'cout' is ambiguous if(sumX == 0 && sumN == 0) cout<<"infinit"; ^ ecuatii.cpp:7:10: note: candidates are: <typeprefixerror>cout ofstream cout("ecuatii.out"); ^ In file included from ecuatii.cpp:1:0: /usr/include/c++/4.8/iostream:61:18: note: std::ostream std::cout extern ostream cout; /// Linked to standard output ^ ecuatii.cpp:98:24: error: reference to 'cout' is ambiguous else if(sumX == 0) cout<<"imposibil"; ^ ecuatii.cpp:7:10: note: candidates are: <typeprefixerror>cout ofstream cout("ecuatii.out"); ^ In file included from ecuatii.cpp:1:0: /usr/include/c++/4.8/iostream:61:18: note: std::ostream std::cout extern ostream cout; /// Linked to standard output ^ ecuatii.cpp:99:10: error: reference to 'cout' is ambiguous else cout<<fixed<<setprecision(4)<<(double)sumN/sumX; ^ ecuatii.cpp:7:10: note: candidates are: <typeprefixerror>cout ofstream cout("ecuatii.out"); ^ In file included from ecuatii.cpp:1:0: /usr/include/c++/4.8/iostream:61:18: note: std::ostream std::cout extern ostream cout; /// Linked to standard output ^ ecuatii.cpp:100:5: error: reference to 'cout' is ambiguous cout<<'\n'; ^ ecuatii.cpp:7:10: note: candidates are: <typeprefixerror>cout ofstream cout("ecuatii.out"); ^ In file included from ecuatii.cpp:1:0: /usr/include/c++/4.8/iostream:61:18: note: std::ostream std::cout extern ostream cout; /// Linked to standard output ^ ecuatii.cpp: In function 'int main()': ecuatii.cpp:107:5: error: reference to 'cin' is ambiguous cin>>n; ^ ecuatii.cpp:6:10: note: candidates are: <typeprefixerror>cin ifstream cin("ecuatii.in"); ^ In file included from ecuatii.cpp:1:0: /usr/include/c++/4.8/iostream:60:18: note: std::istream std::cin extern istream cin; /// Linked to standard input ^ ecuatii.cpp:108:5: error: reference to 'cin' is ambiguous cin.get(); ^ ecuatii.cpp:6:10: note: candidates are: <typeprefixerror>cin ifstream cin("ecuatii.in"); ^ In file included from ecuatii.cpp:1:0: /usr/include/c++/4.8/iostream:60:18: note: std::istream std::cin extern istream cin; /// Linked to standard input ^ ecuatii.cpp:111:9: error: reference to 'cin' is ambiguous cin.getline(v[i], 256); ^ ecuatii.cpp:6:10: note: candidates are: <typeprefixerror>cin ifstream cin("ecuatii.in"); ^ In file included from ecuatii.cpp:1:0: /usr/include/c++/4.8/iostream:60:18: note: std::istream std::cin extern istream cin; /// Linked to standard input ^
www.pbinfo.ro permite evaluarea a două tipuri de probleme:
Problema Ecuatii 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ă.