الفريق العربي للبرمجةأرشيف المنتديات · 2000 – 2023
نسخة أرشيفية للقراءة فقط — التسجيل والمشاركة مغلقان، والمحتوى محفوظ كما كان.

مشكل في دالة ترجع مؤشر على جدول

بدأه noourr في 12 أكتوبر 2014 · 3 رد · 1,595 مشاهدة · في لغة C و ++C
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

السلام عليكم و رحمة الله

 عملت برنامج فيه دالة و ضفتها تبحث عن max كل خط المصفوفة A[][] ثم تضعه في جدول tmax[] ث ثم   يكون الناتج موشر ع هىذا الجدول  tmax

ولكن النشكل عند استعراض البنام يظهر ماكس السطر الاول و الباقي يظهر ارقام طولة اضنها عنوان  الماكسميم  

#include <stdlib.h>#include <stdio.h>typedef struct { int A [20][30];               int m,n;} mat;               mat lecture () {         mat s ;         int i , j;         printf (" svp donner n et m \n");         scanf ("%d %d", &s.n, &s.m);         for (i=0;i<s.n;i++)           for (j=0;j<s.m;j++)               scanf ("%d",&s.A[j]);   return s;}                      void affichage (mat s) {      int i,j;      printf ("le nombre de ligne = %d \n nombre de colonne = %d \n ",s.n,s.m);      for (  i=0;i<s.n;i++)          {for (  j=0 ; j<s.m;j++)              printf ("%d \t" ,s.A[j]);                         printf( "\n");          }             } void max_ligne (mat s , int tmax [20]){ int i,j;      for (   i=0;i<s.n;i++)      {          tmax=s.A[0];          for (  j=1;j<s.m;j++)              if (s.A[j] >tmax)              tmax=s.A[j]   ;                }}             int  *max_ligne2(mat s) {     int i,j;       int tmax[20];       int *p;     for (   i=0;i<s.n;i++)      {          tmax=s.A[0];          for (  j=1;j<s.m;j++)            {   if (s.A[j] >tmax)              tmax=s.A[j]   ;                }      }          p= tmax ;     return   p; }                  main(){       mat r;     int  t[20],i,j,n;    int *q;       r= lecture();               affichage(r);         q= max_ligne2(r);  for(i=0;i<r.n;i++)        printf("le max de la ligne %d  est %d \n",i , *q);           system ("pause");      }

post-282432-0-77572900-1413124841_thumb.

#3

salut

 [][]je veux faire une fonction qui determine le max de chaque ligne d une matrice A  
 

[][]cette fonction retourne un pointeur sur le tableau tmax[] qui contient les max des lignes de A

 

!!!!!!!mais  dès le return je perdre le resultat

 

 

"je sais que ca marche avec la fonction "void max_ligne (mat s , int tma )   mais je veux comprendre pour quoi ca  n marche pas avec les POINEURS  ""la 2 eme fonction 

 

et merci de votre reponse

#4

لم الكلام بغير العربية!

2 −1

مواضيع مشابهة

عدد الزوار حالياً

المتواجدون خلال آخر دقيقتين · يتحدّث كل ٣٠ ثانية

—الإجمالي—أعضاء مسجّلون—زوار بدون تسجيل

جارٍ التحقق من المتواجدين…