Bessan Jadallah نشر 25 أبريل 2020 أرسل تقرير مشاركة نشر 25 أبريل 2020 1 اقتباس رابط هذا التعليق شارك على الشبكات الإجتماعية More sharing options...
0 Mohamed Boussaid نشر 25 أبريل 2020 أرسل تقرير مشاركة نشر 25 أبريل 2020 #include <string.h> int mat[3][3] , b[9]; int i , j , k ; /// 1 void Add(){ /* get the matrix entries from the user */ printf("Enter your entries for the input mat:\n"); for (i = 0; i < 3; i++) { for (j = 0; j < 3; j++) { scanf("%d", &mat[i][j]); } } } /// 2 void RowTotal(){ for( i = 0; i < 3 ; i++){ for( j = 0; j < 3 ; j++){ Total+=mat[i][j]; } printf("%d" , Total); } /// 3 void CFunction(){ for( i = 0; i < 3 ; i++){ for( j = 0; j < 3 ; j++){ if(i == j ){ printf("[%d]" , mat[i][j]); } } } } //// 4 function SortMat(){ // Convert All Array to 1d array k =0 ; for(i=0;i<3;i++) { for(j=0;j<3;j++) b[k++]=mat[i][j]; } /// sort the 1d array int temp ; for (i=0;i<9;i++) { for (j=0;j<(8-i);j++) { if(b[j]>b[j+1]) { temp = b[j]; b[j] = b[j+1]; b[j+1] = temp; } } } /// conver 1d to 2d k=0; for(i=0;i<3;i++) { for(j=0;j<3;j++) { arr[i][j]=b[k]; k++; } } } int Max(){ int matmax = mat[0][0]; for(i=0;i<3;i++) { for(j=0;j<3;j++) { if(mat[i][j] > matmax){ matmax = mat[i][j]; } } } return matmax; } ///6 void PrintArr(){ for(i=0;i<3;i++) { for(j=0;j<3;j++) { printf("%d ",mat[i][j]); } printf("\n"); } } /// 7 void Total(){ int Tot = 0 ; for(i=0;i<3;i++) { for(j=0;j<3;j++) { Tot+=mat[i][j]; } } printf("\nTotal is : %d" , Tot); } } void Main(){ // call function here Add(); RowTotal(); CFunction(); SortMat(); printf("%d" , Max()); PrintArr(); Total(); } Exe.c 2 اقتباس رابط هذا التعليق شارك على الشبكات الإجتماعية More sharing options...
0 Bessan Jadallah نشر 26 أبريل 2020 الكاتب أرسل تقرير مشاركة نشر 26 أبريل 2020 (معدل) Thank you تم التعديل في 26 أبريل 2020 بواسطة Bessan Jadallah اقتباس رابط هذا التعليق شارك على الشبكات الإجتماعية More sharing options...
السؤال
Bessan Jadallah
رابط هذا التعليق
شارك على الشبكات الإجتماعية
2 أجوبة على هذا السؤال
Recommended Posts
انضم إلى النقاش
يمكنك أن تنشر الآن وتسجل لاحقًا. إذا كان لديك حساب، فسجل الدخول الآن لتنشر باسم حسابك.