#241
Interclasare
Se dau două şiruri a
şi b
, cu n
, respectiv m
elemente, numere naturale, ordonate crescător. Să se construiască un al treilea şir, c
, care să conţină, în ordine crescătoare, elementele din şirurile a
şi b
.
Problema | Interclasare | Operații I/O |
interclasare.in /interclasare.out
|
---|---|---|---|
Limita timp | 0.5 secunde | Limita memorie |
Total: 64 MB
/
Stivă 32 MB
|
Id soluție | #54951374 | Utilizator | |
Fișier | interclasare.cpp | Dimensiune | 770 B |
Data încărcării | 13 Decembrie 2024, 11:15 | Scor / rezultat | Eroare de compilare |
interclasare.cpp:1:21: warning: extra tokens at end of #include directive [enabled by default] #include <iostream> #include <fstream> #include <vector> ^ interclasare.cpp: In function 'int main()': interclasare.cpp:3:17: error: variable 'std::ifstream fin' has initializer but incomplete type ifstream fin("interclasare.in"); ^ interclasare.cpp:4:18: error: variable 'std::ofstream fout' has initializer but incomplete type ofstream fout("interclasare.out"); ^ interclasare.cpp:7:5: error: 'vector' was not declared in this scope vector<int> a(n); ^ interclasare.cpp:7:12: error: expected primary-expression before 'int' vector<int> a(n); ^ interclasare.cpp:7:12: error: expected ';' before 'int' interclasare.cpp:9:14: error: 'a' was not declared in this scope { fin >> a[i]; } ^ interclasare.cpp:11:12: error: expected primary-expression before 'int' vector<int> b(m); ^ interclasare.cpp:11:12: error: expected ';' before 'int' interclasare.cpp:13:14: error: 'b' was not declared in this scope { fin >> b[i]; } ^ interclasare.cpp:14:13: error: expected primary-expression before 'int' vector<int> c; int i = 0, j = 0; while (i < n && j < m) { if (a[i] < b[j]) { c.push_back(a[i]); ++i; } else { c.push_back(b[j]); ++j; } } while (i < n) { c.push_back(a[i]); ++i;} while (j < m) { c.push_back(b[j]); ++j; } for (int i = 0; i < c.size(); ++i) { fout << c[i] << " "; if ((i + 1) % 10 == 0) { fout << "\n"; } } if (c.size() % 10 != 0) { fout << "\n"; } return 0; } ^ interclasare.cpp:14:13: error: expected ';' before 'int' interclasare.cpp:14:68: error: 'a' was not declared in this scope vector<int> c; int i = 0, j = 0; while (i < n && j < m) { if (a[i] < b[j]) { c.push_back(a[i]); ++i; } else { c.push_back(b[j]); ++j; } } while (i < n) { c.push_back(a[i]); ++i;} while (j < m) { c.push_back(b[j]); ++j; } for (int i = 0; i < c.size(); ++i) { fout << c[i] << " "; if ((i + 1) % 10 == 0) { fout << "\n"; } } if (c.size() % 10 != 0) { fout << "\n"; } return 0; } ^ interclasare.cpp:14:75: error: 'b' was not declared in this scope vector<int> c; int i = 0, j = 0; while (i < n && j < m) { if (a[i] < b[j]) { c.push_back(a[i]); ++i; } else { c.push_back(b[j]); ++j; } } while (i < n) { c.push_back(a[i]); ++i;} while (j < m) { c.push_back(b[j]); ++j; } for (int i = 0; i < c.size(); ++i) { fout << c[i] << " "; if ((i + 1) % 10 == 0) { fout << "\n"; } } if (c.size() % 10 != 0) { fout << "\n"; } return 0; } ^ interclasare.cpp:14:83: error: 'c' was not declared in this scope vector<int> c; int i = 0, j = 0; while (i < n && j < m) { if (a[i] < b[j]) { c.push_back(a[i]); ++i; } else { c.push_back(b[j]); ++j; } } while (i < n) { c.push_back(a[i]); ++i;} while (j < m) { c.push_back(b[j]); ++j; } for (int i = 0; i < c.size(); ++i) { fout << c[i] << " "; if ((i + 1) % 10 == 0) { fout << "\n"; } } if (c.size() % 10 != 0) { fout << "\n"; } return 0; } ^ interclasare.cpp:14:116: error: 'c' was not declared in this scope vector<int> c; int i = 0, j = 0; while (i < n && j < m) { if (a[i] < b[j]) { c.push_back(a[i]); ++i; } else { c.push_back(b[j]); ++j; } } while (i < n) { c.push_back(a[i]); ++i;} while (j < m) { c.push_back(b[j]); ++j; } for (int i = 0; i < c.size(); ++i) { fout << c[i] << " "; if ((i + 1) % 10 == 0) { fout << "\n"; } } if (c.size() % 10 != 0) { fout << "\n"; } return 0; } ^ interclasare.cpp:14:161: error: 'c' was not declared in this scope vector<int> c; int i = 0, j = 0; while (i < n && j < m) { if (a[i] < b[j]) { c.push_back(a[i]); ++i; } else { c.push_back(b[j]); ++j; } } while (i < n) { c.push_back(a[i]); ++i;} while (j < m) { c.push_back(b[j]); ++j; } for (int i = 0; i < c.size(); ++i) { fout << c[i] << " "; if ((i + 1) % 10 == 0) { fout << "\n"; } } if (c.size() % 10 != 0) { fout << "\n"; } return 0; } ^ interclasare.cpp:14:173: error: 'a' was not declared in this scope vector<int> c; int i = 0, j = 0; while (i < n && j < m) { if (a[i] < b[j]) { c.push_back(a[i]); ++i; } else { c.push_back(b[j]); ++j; } } while (i < n) { c.push_back(a[i]); ++i;} while (j < m) { c.push_back(b[j]); ++j; } for (int i = 0; i < c.size(); ++i) { fout << c[i] << " "; if ((i + 1) % 10 == 0) { fout << "\n"; } } if (c.size() % 10 != 0) { fout << "\n"; } return 0; } ^ interclasare.cpp:14:203: error: 'c' was not declared in this scope vector<int> c; int i = 0, j = 0; while (i < n && j < m) { if (a[i] < b[j]) { c.push_back(a[i]); ++i; } else { c.push_back(b[j]); ++j; } } while (i < n) { c.push_back(a[i]); ++i;} while (j < m) { c.push_back(b[j]); ++j; } for (int i = 0; i < c.size(); ++i) { fout << c[i] << " "; if ((i + 1) % 10 == 0) { fout << "\n"; } } if (c.size() % 10 != 0) { fout << "\n"; } return 0; } ^ interclasare.cpp:14:215: error: 'b' was not declared in this scope vector<int> c; int i = 0, j = 0; while (i < n && j < m) { if (a[i] < b[j]) { c.push_back(a[i]); ++i; } else { c.push_back(b[j]); ++j; } } while (i < n) { c.push_back(a[i]); ++i;} while (j < m) { c.push_back(b[j]); ++j; } for (int i = 0; i < c.size(); ++i) { fout << c[i] << " "; if ((i + 1) % 10 == 0) { fout << "\n"; } } if (c.size() % 10 != 0) { fout << "\n"; } return 0; } ^ interclasare.cpp:14:250: error: 'c' was not declared in this scope vector<int> c; int i = 0, j = 0; while (i < n && j < m) { if (a[i] < b[j]) { c.push_back(a[i]); ++i; } else { c.push_back(b[j]); ++j; } } while (i < n) { c.push_back(a[i]); ++i;} while (j < m) { c.push_back(b[j]); ++j; } for (int i = 0; i < c.size(); ++i) { fout << c[i] << " "; if ((i + 1) % 10 == 0) { fout << "\n"; } } if (c.size() % 10 != 0) { fout << "\n"; } return 0; } ^ interclasare.cpp:14:335: error: 'c' was not declared in this scope vector<int> c; int i = 0, j = 0; while (i < n && j < m) { if (a[i] < b[j]) { c.push_back(a[i]); ++i; } else { c.push_back(b[j]); ++j; } } while (i < n) { c.push_back(a[i]); ++i;} while (j < m) { c.push_back(b[j]); ++j; } for (int i = 0; i < c.size(); ++i) { fout << c[i] << " "; if ((i + 1) % 10 == 0) { fout << "\n"; } } if (c.size() % 10 != 0) { fout << "\n"; } return 0; } ^
www.pbinfo.ro permite evaluarea a două tipuri de probleme:
Problema Interclasare 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ă.