Erreur d'affichage Matrice
pointAbed
Messages postés
1
Date d'inscription
Statut
Membre
Dernière intervention
-
abdelouafi1 Messages postés 5 Date d'inscription Statut Membre Dernière intervention -
abdelouafi1 Messages postés 5 Date d'inscription Statut Membre Dernière intervention -
Voilà le code :
#include<stdio.h>
int main()
{int i,j;
int M[3][3];
//lecture Matrice
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
printf("donner l element [%d][%d]",i,j);
scanf("%d",&M[i][j]);
}
}
//Affichage
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
printf("%d",M[i][j]);
}
printf("\n");
}
}
je sais pas pourquoi , après compilation , la matrice lis des indices 00 jusqu'à 31 ?!
Aide moi svp
#include<stdio.h>
int main()
{int i,j;
int M[3][3];
//lecture Matrice
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
printf("donner l element [%d][%d]",i,j);
scanf("%d",&M[i][j]);
}
}
//Affichage
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
printf("%d",M[i][j]);
}
printf("\n");
}
}
je sais pas pourquoi , après compilation , la matrice lis des indices 00 jusqu'à 31 ?!
Aide moi svp
A voir également:
- Erreur d'affichage Matrice
- Affichage double ecran - Guide
- Windows 11 affichage classique - Guide
- Problème affichage fenêtre windows 10 - Guide
- Erreur 0x80070643 - Accueil - Windows
- Erreur 0x80070643 Windows 10 : comment résoudre le problème de la mise à jour KB5001716 - Accueil - Windows
2 réponses
Je n'ai pas de problème:
Compilation et exécution:
johand@bata:~/src/CCM/C$ gcc -Wall -o print_mat print_mat.c
johand@bata:~/src/CCM/C$ echo 1 2 3 4 5 6 7 8 9 10 | ./print_mat
1 2
3 4
5 6
7 8
9 10
#include <stdlib.h> #include <stdio.h> const int ROWS = 5, COLS = 2; int main(int argc, char* argv[]) { int i,j; int M[ROWS][COLS]; //lecture Matrice for(i = 0; i < ROWS; i++) { for(j = 0; j < COLS; j++) { /* printf("donner l element [%d][%d]", i, j); */ scanf("%d", &M[i][j]); } } //Affichage for(i = 0; i < ROWS; i++) { for(j = 0; j < COLS; j++) { printf("%d ", M[i][j]); } printf("\n"); } }
Compilation et exécution:
johand@bata:~/src/CCM/C$ gcc -Wall -o print_mat print_mat.c
johand@bata:~/src/CCM/C$ echo 1 2 3 4 5 6 7 8 9 10 | ./print_mat
1 2
3 4
5 6
7 8
9 10
La réponse à votre question je l'ai mis sur mon site , voici le lien:
https://www.exam-lib.com/threads/les-matrices-%C3%A0-deux-dimensions-en-langage-c-tableaux-2-dimension.369/
si vous avez d'autres questions merci de me contacter
https://www.exam-lib.com/threads/les-matrices-%C3%A0-deux-dimensions-en-langage-c-tableaux-2-dimension.369/
si vous avez d'autres questions merci de me contacter