[[Template core/front/global/updateWarning is throwing an error. This theme may be out of date. Run the support tool in the AdminCP to restore the default theme.]]
البرنامج يطلب قراءة جدول dynamique à 2 dimensions ثم تقسيمه الى جدولين حيث احدهما يحوي الاعداد الزوجيه فقط و الثاني الفردية فقط ، هذا الكود لا اجد الحلل فارجو المساعدة
#include<stdio.h>#include<stdlib.h>main(){ int (*tab)[2],(*Tp)[2],(*Ti)[2]; int i,j,n=0,m=0; int np=0,mp=0,ni=0,mi=0; printf("donner le nombre de lignes\t"); scanf("%d",&n); printf("donner le nombre de colonnes\t"); scanf("%d",&m); //allocation dynamique du tableau tab = malloc(n*m*sizeof(int)); //lecture du tableau for(i=0;i<n;i++) { for(j=0;j<m;j++) { printf("donner un reel\t"); scanf("%d",&tab[i][j]); } } //affichage du tableau printf("\nvoila votre tableau:\n"); for(i=0;i<n;i++) { for(j=0;j<m;j++) { printf("%d\t",tab[i][j]); } } //éclater le tableau en 2 for(i=0;i<n;i++) { for(j=0;j<m;j++) { if (tab[i][j]%2==0) { np++; mp++; Tp = malloc(np*mp*sizeof(int)); Tp[np][mp]=tab[i][j]; }else{ ni++; mi++; Ti = malloc(ni*mi*sizeof(int)); Ti[ni][mi]=tab[i][j]; } } } //affichage des 2 tableaux printf("\nle tableau des nombres paires : %d\t",Tp[np][mp]); printf("\nle tableau des nombres impaires: %d\t",Ti[ni][mi]); //libérer l'espace mémoire des tableaux free(tab); free(Tp); free(Ti);return 0;system("pause");}
تم النشر منذ
البرنامج يطلب قراءة جدول dynamique à 2 dimensions ثم تقسيمه الى جدولين حيث احدهما يحوي الاعداد الزوجيه فقط و الثاني الفردية فقط ، هذا الكود لا اجد الحلل فارجو المساعدة
:( :( :(
شارك هذا الرد
رابط المشاركة
شارك الرد من خلال المواقع ادناه