#4060
Se dă un graf neorientat cu n vârfuri și un număr natural k. Să se afișeze vârfurile din graf care au gradul egal cu k.
| Problema | GradK | Operații I/O |
gradk.in/gradk.out
|
|---|---|---|---|
| Limita timp | 0.1 secunde | Limita memorie |
Total: 64 MB
/
Stivă 8 MB
|
| Id soluție | #63694993 | Utilizator | |
| Fișier | gradk.cpp | Dimensiune | 882 B |
| Data încărcării | 15 Martie 2026, 15:41 | Scor/rezultat | Eroare de compilare |
gradk.cpp: In function 'void citire()': gradk.cpp:3:5: error: 'ifstream' was not declared in this scope ifstream fin("gradk.in"); ^ gradk.cpp:3:14: error: expected ';' before 'fin' ifstream fin("gradk.in"); ^ gradk.cpp:5:5: error: 'fin' was not declared in this scope fin >> n >> k; ^ gradk.cpp:5:12: error: 'n' was not declared in this scope fin >> n >> k; ^ gradk.cpp:5:17: error: 'k' was not declared in this scope fin >> n >> k; ^ gradk.cpp:7:9: error: 'v' was not declared in this scope v[i][j] = v[j][i] = 1; // graf neorientat, matrice de adiacență ^ gradk.cpp: In function 'void calculeaza_grad()': gradk.cpp:12:25: error: 'n' was not declared in this scope for(int i = 1; i <= n; i++) { ^ gradk.cpp:13:9: error: 'grad' was not declared in this scope grad[i] = 0; ^ gradk.cpp:15:16: error: 'v' was not declared in this scope if(v[i][j] == 1) grad[i]++; ^ gradk.cpp: In function 'int main()': gradk.cpp:23:5: error: 'ofstream' was not declared in this scope ofstream fout("gradk.out"); ^ gradk.cpp:23:14: error: expected ';' before 'fout' ofstream fout("gradk.out"); ^ gradk.cpp:26:25: error: 'n' was not declared in this scope for(int i = 1; i <= n; i++) ^ gradk.cpp:27:12: error: 'grad' was not declared in this scope if(grad[i] == k) cnt++; ^ gradk.cpp:27:23: error: 'k' was not declared in this scope if(grad[i] == k) cnt++; ^ gradk.cpp:30:9: error: 'fout' was not declared in this scope fout << "NU EXISTA" << endl; ^ gradk.cpp:30:32: error: 'endl' was not declared in this scope fout << "NU EXISTA" << endl; ^ gradk.cpp:32:9: error: 'fout' was not declared in this scope fout << cnt << endl; ^ gradk.cpp:32:24: error: 'endl' was not declared in this scope fout << cnt << endl; ^ gradk.cpp:33:29: error: 'n' was not declared in this scope for(int i = 1; i <= n; i++) ^ gradk.cpp:34:16: error: 'grad' was not declared in this scope if(grad[i] == k) ^ gradk.cpp:34:27: error: 'k' was not declared in this scope if(grad[i] == k) ^
www.pbinfo.ro permite evaluarea a două tipuri de probleme:
Problema GradK 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ă.