Commit a299f310 by videid

commit

parent afe04b92
No preview for this file type
No preview for this file type
...@@ -6,15 +6,20 @@ ...@@ -6,15 +6,20 @@
void size(int* rows,int* columns); void size(int* rows,int* columns);
void fill(int rows,int columns); void fill(int *rows,int *columns,int myArray[] );
void maxro(int rows,int columns,int myArray[],int d);
void sumro(int rows,int columns,int myArray[],int d);
void sortro(int rows,int columns,int myArray[]);
int main(void){ int main(void){
int rows ; int rows ;
int columns ; int columns ;
int d=0;
int myArray[]={0};
size(&rows,&columns); size(&rows,&columns);
fill(rows,columns); fill(&rows,&columns,&myArray[rows*columns]);
maxro(rows,columns,&myArray[rows*columns],d);
sumro(rows,columns,&myArray[rows*columns],d);
sortro(rows,columns,&myArray[rows*columns]);
return 0 ; return 0 ;
...@@ -36,23 +41,110 @@ void size(int *rows,int *columns){ ...@@ -36,23 +41,110 @@ void size(int *rows,int *columns){
} }
printf("%d rows %d columns \n",*rows,*columns); printf("%d rows %d columns \n",*rows,*columns);
} }
void fill(int rows,int columns){ void fill(int *rows,int *columns,int myArray[]){
int h; int h;
int i; int i;
int j; int j;
int myArray[rows][columns]; int a = *rows;
for (i=0 ;i< rows ;i++){ int b = *columns;
for(j=0;j<columns;j++){ for (i=1 ;i<= a*b ;i=i+b){
for(j=1;j<=b;j++){
printf("enter number \n"); printf("enter number \n");
scanf("%d", &h); scanf("%d", &h);
myArray[i][j] = h; myArray[i+j] = h;
}
}
for (i=1 ;i<= a*b ;i=i+b){
for(j=1;j<=b;j++){
printf("%d",myArray[i+j]);
}
printf("\n");
}
}
void maxro(int rows,int columns,int myArray[],int d){
int h;
int i;
int j;
int a = rows;
int b = columns;
for (i=1 ;i<= a*b ;i=i+b){
for(j=1;j<=b;j++){
if(myArray[i+j]>d){
d=myArray[i+j];
}
} }
printf("%d\n",d);
}
}
void sortro(int rows,int columns,int myArray[]){
int a = rows;
int b = columns;
int k;
int g;
int i ;
int j;
int u;
int temp ;
for (k = 0; k <a*b ; k=k+b){
for (i = k; i < b; i++){
for (g = k;g <b-1-i; g++ ){
if (myArray[g] > myArray[g+1]){
temp = myArray[g+1];
myArray[g+1] = myArray[g];
myArray[g] = temp;
for (u=1 ;u<= a*b ;u=u+b){
for(j=1;j<=b;j++){
printf("%d",myArray[i+j]);
}
printf("\n");
}
}
}
}
} }
for (i=0 ;i< rows ;i++){ }
for(j=0;j<columns;j++){ void sumro(int rows,int columns,int myArray[],int d){
printf("%d",myArray[i][j]);
int h;
int i;
int j;
int index;
int a = rows;
int b = columns;
int k[a] ;
for (i=1 ;i<=a*b ;i=i+b){
k[i] = 0;
for(j=1;j<=b;j++){
k[i]=k[i]+myArray[i+j];
} }
printf("\n"); printf("%d\n",k[i]);
}
for (i=1 ;i<=a*b ;i=i+b){
if (k[i]>d){
d= k[i];
index = i;
}
printf("%d is the max sum row\n",index);
} }
} }
No preview for this file type
No preview for this file type
...@@ -6,16 +6,16 @@ ...@@ -6,16 +6,16 @@
void size(int* rows,int* columns); void size(int* rows,int* columns);
void fill(int rows,int columns,int(*myArray)[rows][columns]); void fill(int *rows,int *columns );
void print(int rows,int columns,int(*myArray)[rows][columns]); //void disp(int rows,int columns,int myArray[rows+columns]);
int main(void){ int main(void){
int rows ; int rows ;
int columns ; int columns ;
int myArray[rows][columns];
size(&rows,&columns); size(&rows,&columns);
fill(rows,columns,&myArray[rows][columns]); fill(&rows,&columns);
print(rows,columns,myArray[rows][columns]); // disp(rows,columns,&myArray[rows+columns]);
...@@ -36,28 +36,35 @@ void size(int *rows,int *columns){ ...@@ -36,28 +36,35 @@ void size(int *rows,int *columns){
scanf("%d", columns); scanf("%d", columns);
} }
printf("%d %d",*rows,*columns); printf("%d rows %d columns \n",*rows,*columns);
} }
void fill(int rows,int columns,int(*myArray)[rows][columns]){ void fill(int *rows,int *columns){
int h; int h;
int i; int i;
int j; int j;
for (i=0 ;i< rows ;i++){ int a = *rows;
for(j=0;j<columns;j++){ int b = *columns;
int myArray[a*b];
for (i=1 ;i<= a*b ;i=i+b){
for(j=1;j<=b;j++){
printf("enter number \n"); printf("enter number \n");
scanf("%d", &h); scanf("%d", &h);
myArray[i][j] = h; myArray[i+j] = h;
} }
} }
for (i=1 ;i<= a*b ;i=i+b){
for(j=1;j<=b;j++){
printf("%d",myArray[i+j]);
}
void print(int rows,int columns,int myArray[rows][columns]){
for (i=0 ;i< rows ;i++){
for(j=0;j<columns;j++){
printf("%d",h);
} }
printf("\n"); printf("\n");
} }
} }
//void disp(int rows,int columns,int myArray[rows+columns]){
//
//}
File added
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment