Advertisement
Guest User

Untitled

a guest
Dec 9th, 2019
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. #include <stdio.h>
  2. #define R 3
  3. #define C 3
  4. main (){
  5. int matrice[R][C];
  6. int i,j,m,n;
  7. printf("Inserisci dei valori nella matrice 3x3\n");
  8. /* lettura matrice */
  9. for(i=0;i<R;i++){
  10. printf("Riga %d\n",i);
  11. for(j=0;j<C;j++){
  12. printf("Inserisci l'elemento\n",j);
  13. scanf("%d",&matrice[i][j]);
  14. }
  15. }
  16. /* stampa matrice */
  17. for(i=0;i<R;i++){
  18. for(j=0;j<C;j++){
  19. printf("%d",matrice[i][j]);
  20. }
  21. printf("\n");
  22. }
  23. /* verifica della presenza di elementi duplicati nelle righe */
  24. for(i=0;i<R;i++){
  25. for(j=0;j<C;j++){
  26. if(matrice[i][0]==matrice[i+1][0]){
  27. m=1;
  28. }
  29. }
  30. }
  31. /* verfica della presenza di elementi duplicati nelle colonne */
  32. for(i=0;i<R;i++){
  33. for(j=0;j<C;j++){
  34. if(matrice[0][j]==matrice[0][j+1]){
  35. n=1;
  36. }
  37. }
  38. }
  39. if((m==1)&&(n==1)){
  40. printf("Non e' un sudoku");
  41. }
  42. else{
  43. printf("E' un sudoku");
  44. }
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement