Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #define R 3
- #define C 3
- main (){
- int matrice[R][C];
- int i,j,m,n;
- printf("Inserisci dei valori nella matrice 3x3\n");
- /* lettura matrice */
- for(i=0;i<R;i++){
- printf("Riga %d\n",i);
- for(j=0;j<C;j++){
- printf("Inserisci l'elemento\n",j);
- scanf("%d",&matrice[i][j]);
- }
- }
- /* stampa matrice */
- for(i=0;i<R;i++){
- for(j=0;j<C;j++){
- printf("%d",matrice[i][j]);
- }
- printf("\n");
- }
- /* verifica della presenza di elementi duplicati nelle righe */
- for(i=0;i<R;i++){
- for(j=0;j<C;j++){
- if(matrice[i][0]==matrice[i+1][0]){
- m=1;
- }
- }
- }
- /* verfica della presenza di elementi duplicati nelle colonne */
- for(i=0;i<R;i++){
- for(j=0;j<C;j++){
- if(matrice[0][j]==matrice[0][j+1]){
- n=1;
- }
- }
- }
- if((m==1)&&(n==1)){
- printf("Non e' un sudoku");
- }
- else{
- printf("E' un sudoku");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement