#202
Se citeşte un număr natural nenul n. Să se afişeze, în ordine lexicografică, permutările fără puncte fixe ale mulţimii {1,2,..,n}.
| Problema | PermPF | Operații I/O |
permpf.in/permpf.out
|
|---|---|---|---|
| Limita timp | 0.5 secunde | Limita memorie |
Total: 64 MB
/
Stivă 8 MB
|
| Id soluție | #64268034 | Utilizator | |
| Fișier | permpf.cpp | Dimensiune | 679 B |
| Data încărcării | 27 Aprilie 2026, 11:35 | Scor/rezultat | Eroare de compilare |
permpf.cpp:4:1: error: expected ‘,’ or ‘;’ before ‘ofstream’ 4 | ofstream fout("permpf.out") | ^~~~~~~~ permpf.cpp: In function ‘int valid(int)’: permpf.cpp:9:8: error: ‘v’ was not declared in this scope 9 | if(v[k]==k)return 0; | ^ permpf.cpp:11:12: error: ‘v’ was not declared in this scope 11 | if(v[i]==v[k])return 0;return 1; | ^ permpf.cpp:11:9: warning: this ‘if’ clause does not guard... [-Wmisleading-indentation] 11 | if(v[i]==v[k])return 0;return 1; | ^~ permpf.cpp:11:32: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the ‘if’ 11 | if(v[i]==v[k])return 0;return 1; | ^~~~~~ permpf.cpp:10:5: warning: this ‘for’ clause does not guard... [-Wmisleading-indentation] 10 | for(i=1;i<=k-1;i++) | ^~~ permpf.cpp:11:32: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the ‘for’ 11 | if(v[i]==v[k])return 0;return 1; | ^~~~~~ permpf.cpp: In function ‘int solutie(int)’: permpf.cpp:15:11: error: ‘n’ was not declared in this scope 15 | if(k==n) | ^ permpf.cpp:15:5: warning: this ‘if’ clause does not guard... [-Wmisleading-indentation] 15 | if(k==n) | ^~ permpf.cpp:16:18: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the ‘if’ 16 | return 1;return 0; | ^~~~~~ permpf.cpp: In function ‘void afisare(int)’: permpf.cpp:21:22: error: ‘fout’ was not declared in this scope 21 | for(i=1;i<=k;i++)fout<<v[i]<<' ';fout<<'\n'; | ^~~~ permpf.cpp:21:28: error: ‘v’ was not declared in this scope 21 | for(i=1;i<=k;i++)fout<<v[i]<<' ';fout<<'\n'; | ^ permpf.cpp:21:5: warning: this ‘for’ clause does not guard... [-Wmisleading-indentation] 21 | for(i=1;i<=k;i++)fout<<v[i]<<' ';fout<<'\n'; | ^~~ permpf.cpp:21:38: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the ‘for’ 21 | for(i=1;i<=k;i++)fout<<v[i]<<' ';fout<<'\n'; | ^~~~ permpf.cpp:21:38: error: ‘fout’ was not declared in this scope permpf.cpp: In function ‘void backt(int)’: permpf.cpp:27:16: error: ‘n’ was not declared in this scope 27 | for(i=1;i<=n;i++) | ^ permpf.cpp:29:9: error: ‘v’ was not declared in this scope 29 | v[k]=i; | ^ permpf.cpp:30:11: warning: suggest explicit braces to avoid ambiguous ‘else’ [-Wdangling-else] 30 | if(valid(k)==1) | ^ permpf.cpp: In function ‘int main()’: permpf.cpp:37:8: error: ‘n’ was not declared in this scope 37 | fin>>n;backt(1); | ^ permpf.cpp:39:3: error: ‘fout’ was not declared in this scope 39 | fout.close(): | ^~~~
www.pbinfo.ro permite evaluarea a două tipuri de probleme:
Problema PermPF 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ă.