Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include <ctype.h>
- void swap(int *a, int *b) {
- int pom = *a;
- *a = *b;
- *b = pom;
- }
- int main(int argc, char * argv[])
- {
- int red, koloni;
- scanf("%d%d", &red, &koloni);
- int mat[300][300];
- for(int i = 0; i < red; i++) {
- for(int j = 0; j < koloni; j++) {
- scanf("%d", &mat[i][j]);
- }
- }
- int sum_najgolem1 = 0;
- int idx = 0;
- for(int j = 0; j < koloni; j++) {
- int sum = 0;
- for(int i = 0; i < red; i++) {
- sum += mat[i][j];
- }
- if(sum > sum_najgolem1) {
- sum_najgolem1 = sum;
- idx = j;
- }
- }
- int sum_najgolem2 = 0;
- int idx2 = 0;
- for(int j = 0; j < koloni; j++) {
- int sum = 0;
- for(int i = 0; i < red; i++) {
- sum += mat[i][j];
- }
- if(sum > sum_najgolem2 && idx != j) {
- sum_najgolem2 = sum;
- idx2 = j;
- }
- }
- for(int i = 0; i < red; i++) {
- swap(&mat[i][idx], &mat[i][idx2]);
- }
- for(int i = 0; i < red / 2; i++) {
- swap(&mat[i][idx], &mat[red - i - 1][idx]);
- swap(&mat[i][idx2], &mat[red - i - 1][idx2]);
- }
- for(int i = 0; i < red; i++) {
- for(int j = 0; j < koloni; j++) {
- printf("%d ", mat[i][j]);
- }
- printf("\n");
- }
- return 0;
- }
- /*
- 6 8
- 1 2 3 4 5 6 7 8
- 2 1 2 3 4 5 6 7
- 3 4 5 6 7 8 9 10
- 4 5 6 7 8 9 10 0
- 5 6 7 8 9 10 0 1
- 6 7 8 9 10 0 1 2
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement