Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Project 4 v.6
//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,2,3},{4,5,6},{7,8,9}}; // 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 identidy matrix"); printf("\n\n5."); printf("Array A's Average= %lf\n",FindArrayMean(A)); printf("\n\n6."); printf("\n\n7."); }
run
|
edit
|
history
|
help
0
20171116:FUNCIONES
NOT a String in C - 2
print_odd_pointer.c
Stub Program for Problem 6 HW 2
Array pass effect
Daniel - hw3q2
2.1.1 Prime numbers in different threads with thread ID
Square pyramid
exercises
Primes in binary