Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Project 4 v1.1
//gcc 5.4.0 #include <stdio.h> int FindMax(int A[3][3]){ int MaxVal=A[0][0]; int x,y,n=3; for(x=0;x<n;x++) for(y=0;y<n;y++){ if(A[x][y]>MaxVal) MaxVal=A[x][y]; // printf("%d\n",MaxVal); } return(MaxVal); } int FindMin(int A[3][3]){ int MinVal=A[0][0]; int x,y,n=3; for(x=0;x<n;x++) for(y=0;y<n;y++){ if(A[x][y]<MinVal) MinVal=A[x][y]; // printf("%d\n",MinVal); } return(MinVal); } int FindColumnSum(int A[3][3],int y){ int x,sum=0,n=3; for(x=0;x<n;x++){ sum=sum+A[x][y]; // printf("%d\n",sum); } return(sum); } int FindRowSum(int A[3][3],int x){ int y,sum=0,n=3; for(y=0;y<n;y++){ sum=sum+A[x][y]; // printf("%d\n",sum); } return(sum); } double FindArrayMean(int A[3][3]){ int x,y,sum=0,n=3,m1=0; double mean=0; for(x=0;x<n;x++) for(y=0;y<n;y++){ sum=sum+A[x][y]; // printf("%d\n",sum); m1++; } mean=sum/m1; return(mean); } //int ColumnZeroAss(int A[3][3],int Cz[9]){ // } //int RowZeroAss(intA[3][3],int Rz[9]){ // } int CheckIdentMatrix(int A[3][3]){ int x,y,n=3,c=0; // char no[3]="not"; for(x=0;x<n;x++) for(y=0;y<n;y++){ if(x==y&&A[x][y]==0){ c++; // printf("%d\n",c); } if(x!=y&&A[x][y]!=0){ c++; // printf("%d\n",c); } } return(c); } int main(void) { int A[3][3]={{1,0,0},{0,2,0},{0,0,3}}; int Cz[9]; int Rz[9]; // int MaxVal; int x,y,n=3; printf("\n\n1.\n"); for(x=0;x<n;x++){ printf("Row %d's sum=%d\n",x,FindRowSum(A,x)); } for(y=0;y<n;y++){ printf("Column %d's sum=%d\n",y,FindColumnSum(A,y)); } printf("\n\n2."); printf("Maximum Value of Array A is %d\n",FindMax(A)); printf("\n\n3."); printf("Minimum Value of Array A is %d\n",FindMin(A)); printf("\n\n4."); int cc; cc=CheckIdentMatrix(A); if(cc>0) printf("Array A is not an identidy matrix"); else printf("Array A is an identity matrix"); printf("\n\n5."); printf("Array A's Average= %lf\n",FindArrayMean(A)); printf("\n\n6."); int Rzc=0; printf("Row Major Method=["); for(x=0;x<n;x++) for(y=0;y<n;y++){ Rz[Rzc]=A[x][y]; printf(" %d",Rz[Rzc]); Rzc++; } printf("]\n"); printf("\n\n7."); int Czc=0; printf("Column Major Method=["); for(y=0;y<n;y++) for(x=0;x<n;x++){ Cz[Czc]=A[x][y]; printf(" %d",Cz[Czc]); Czc++; } printf("]\n"); }
run
|
edit
|
history
|
help
0
Eee
Valor fuera del intervalo
kill
co_4
140114_CribaErasthotenes
PUNTEROS 1
C Array Demonstration
PRIMER AVANCE DE NETFLIX
coding!!Woo!!
B_141128_MatrizProducto