#1518
sudoku
Scrieţi un program care, pentru o matrice 9 x 9
dată, reprezentând un puzzle SUDOKU, determină o soluţie a unui astfel de puzzle.
Problema | sudoku | Operații I/O |
sudoku.in /sudoku.out
|
---|---|---|---|
Limita timp | 1 secunde | Limita memorie |
Total: 64 MB
/
Stivă 8 MB
|
Id soluție | #53941935 | Utilizator | |
Fișier | sudoku.cpp | Dimensiune | 1.05 KB |
Data încărcării | 15 Noiembrie 2024, 12:13 | Scor / rezultat | Eroare de compilare |
sudoku.cpp:1:21: warning: extra tokens at end of #include directive [enabled by default] #include <iostream> #include <fstream> #include <conio.h> using namespace std; ifstream fin("sudoku.in"); ofstream fout("sudoku.out"); int a[9][9]; int b[9][9]; int sol[81]; void afis() { for(int i=0;i<=8;i++ , cout<<"\n") { for(int j=0;j<=8;j++) { cout<<a[i][j]<<' '; } } exit(0); } bool verif(int poz) { int lin=poz/9; int col=poz%9; for(int j=0;j<9;j++) { if(a[lin][j]==a[lin][col] && j!=col) { return false; } } for(int i=0;i<9;i++) { if(a[i][col]==a[lin][col] && i!=lin) { return false; } } if(lin%3==2 && col%3==2) { int v[11]={0,0,0,0,0,0,0,0,0,0,0}; for(int i=lin-2;i<=lin;i++) { for(int j=col-2;j<=col;j++) { v[a[i][j]]++; } } for(int i=1;i<=9;i++) { if(v[i]!=1) { return false; } } } return true; } int x; void back(int poz) { int lin=poz/9; int col=poz%9; if(a[lin][col]!=0) { if(poz==80) { afis(); } else { back(poz+1); } } else{ for(int i=1;i<=9;i++) { a[lin][col]=i; if(verif(poz)) { sol[poz]=i; if(poz==80) { afis(); } else { back(poz+1); } } a[lin][col]=0; } } } int main() { for(int i=0;i<=8;i++) { for(int j=0;j<=8;j++) { fin>>a[i][j]; } } back(0); return 0; } ^ /usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_info): relocation 0 has invalid symbol index 11 /usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_info): relocation 1 has invalid symbol index 12 /usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_info): relocation 2 has invalid symbol index 2 /usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_info): relocation 3 has invalid symbol index 2 /usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_info): relocation 4 has invalid symbol index 11 /usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_info): relocation 5 has invalid symbol index 13 /usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_info): relocation 6 has invalid symbol index 13 /usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_info): relocation 7 has invalid symbol index 13 /usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_info): relocation 8 has invalid symbol index 12 /usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_info): relocation 9 has invalid symbol index 13 /usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_info): relocation 10 has invalid symbol index 13 /usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_info): relocation 11 has invalid symbol index 13 /usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_info): relocation 12 has invalid symbol index 13 /usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_info): relocation 13 has invalid symbol index 13 /usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_info): relocation 14 has invalid symbol index 13 /usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_info): relocation 15 has invalid symbol index 13 /usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_info): relocation 16 has invalid symbol index 13 /usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_info): relocation 17 has invalid symbol index 13 /usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_info): relocation 18 has invalid symbol index 13 /usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_info): relocation 19 has invalid symbol index 13 /usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_info): relocation 20 has invalid symbol index 13 /usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_info): relocation 21 has invalid symbol index 22 /usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_line): relocation 0 has invalid symbol index 2 /usr/lib/gcc/i686-linux-gnu/4.8/../../../i386-linux-gnu/crt1.o: In function \`_start': (.text+0x18): undefined reference to \`main' collect2: error: ld returned 1 exit status
www.pbinfo.ro permite evaluarea a două tipuri de probleme:
Problema sudoku 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ă.