Il te faut utiliser les pointeurs.
//La fonction
int ProdMat(int tablo1[][],int tablo2[][],int tablo3[][])
{
//Maintenant il faut coller ici le code de ta fonction
//et les tableaux s'appellent tablo1,tablo2 et tablo3
// n'oublie de faire une ligne pour déclarer tes compteurs
// int i,j,k,l,m,n;
return 0;
}
//Appel dans le main
void main(void)
{
int retour;
//Tu mets le nom des tablos en paramètres
retour = ProdMat(tab1,tab2,tab3);
}
PS1: le code de ta fonction doit etre au dessus du code du main (comme ici) ou sinon tu fais une déclaration.
-------------------------------
Réponse au message :
-------------------------------
> Voici mon programme quelqu'un pourrait-il m'aider je dois faire une fonction et je ne vois pas comment la faire le non de ma fonction doit etre PRODMAT et le code a mettre de dans commence a partir
> "Affectation du r?sultat de la multiplication ? tab3" avec l'afffichage de tab3.
>
>
> > #include <stdio.h> > #include<conio.h> > #include <stdlib.h> > > #define LIM 50 > > main() > { > int tab1[LIM][LIM]; > int tab2[LIM][LIM]; > int tab3[LIM][LIM]; > int n,m,p; > int i,j,k; > > /* Cr?ation cadre */ > clrscr(); > gotoxy(27,20); > printf("ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»"); > gotoxy(27,21); > printf("º Exercice Nø1 - Dossier Nø03 º"); > gotoxy(27,22); > printf("ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ?"); > > getch(); > > /* Saisie des donn?es */ > do > { > clrscr(); > gotoxy(18,2); > printf("ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»"); > gotoxy(18,3); > printf("º -= Matrice al?toirement de 0 et 100 =- º"); > gotoxy(18,4); > printf("ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ?"); > > printf("\n\n\n\n\tPremi?re Matrice"); > printf("\n\n\t Entrez le nombre de ligne (max.50): "); > scanf("%d", &n); > printf("\n\t Entrez le nombre de colonne (max.50): "); > scanf("%d", &m); > > printf("\n\n\tDeuxi?me Matrice"); > printf("\n\n\t Entrez le nombre de ligne: %d\n", m); > printf("\n\t Entrez le nombre de colonne (max.50): "); > scanf("%d", &p ); > } > while ( n<1 || m<1 || p<1); > > > printf("\n\n\t\t Pour poursuivre veuiller taper - ENTER - "); > getch(); > clrscr(); > > > /***********************************************************************************/ > /* Remplisage des ?l?ments Al?atoire du Tableau entre 0 et 100 dans les 2 matrices */ > /***********************************************************************************/ > > /*********************/ > /* Pour la matrice 1 */ > /*********************/ > randomize(); > for (i=0; i<n; i++) > { > for (j=0; j<m; j++) > { > tab1[i][j]=random(101); > } > } > > /*********************/ > /* Pour la matrice 2 */ > /*********************/ > for (i=0; i<m; i++) > for (j=0; j<p; j++) > { > tab2[i][j]=random(101); > } > > > /*****************************/ > /* Affichages des 2 matrices */ > /*****************************/ > > gotoxy(24,2); > printf("ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»"); > gotoxy(24,3); > printf("º -= Affichage des Matrices =- º"); > gotoxy(24,4); > printf("ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ?"); > > /*****************************/ > /* Affichage de la matrice 1 */ > /*****************************/ > printf("\n\n\n\t Premi?re Matrice:\n"); > printf("\n\t"); > for (i=0; i<n ; i++) > { > for (j=0; j<m; j++) > printf(" %7d", tab1[i][j]); > printf("\n\t"); > } > > /*****************************/ > /* Affichage de la matrice 2 */ > /*****************************/ > printf("\n\t Deuxi?me Matrice:\n"); > printf("\n\t"); > for (i=0; i<m; i++) > { > for (j=0; j<p; j++) > printf(" %7d", tab2[i][j]); > printf("\n\t"); > } > > > /*******************************************************/ > /* Affectation du r?sultat de la multiplication ? tab3 */ > /*******************************************************/ > > for (i=0; i<n; i++) > for (j=0; j<p; j++) > { > tab3[i][j]=0; > for (k=0; k<m; k++) > tab3[i][j] += tab1[i][k]*tab2[k][j]; > } > > /*************************/ > /* Affichage du r?sultat */ > /*************************/ > > printf("\n\t Produit Matriciel: \n"); > printf("\n\t"); > for (i=0; i<n; i++) > { > for (j=0; j<p; j++) > printf(" %7d", tab3[i][j]); > printf("\n\t"); > } > > getch(); > > } > |