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>
- 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 maksimalen_element = mat[0][0];
- for(int i = 0; i < red; i++) {
- for(int j = 0; j < koloni; j++) {
- if(mat[i][j] > maksimalen_element) {
- maksimalen_element = mat[i][j];
- }
- }
- }
- int mat2[300][300];
- int novi_koloni = 0;
- for(int j = 0; j < koloni; j++) {
- int ok = 0;
- for(int i = 0; i < red; i++) {
- if(mat[i][j] == maksimalen_element) {
- ok = 1;
- }
- }
- if(ok == 0) {
- for(int i = 0; i < red; i++) {
- mat2[i][novi_koloni] = mat[i][j];
- }
- novi_koloni++;
- }
- }
- int minimalen_element = mat2[0][0];
- for(int i = 0; i < red; i++) {
- for(int j = 0; j < novi_koloni; j++) {
- if(mat[i][j] < minimalen_element) {
- minimalen_element = mat[i][j];
- }
- }
- }
- int novi_redovi = 0;
- int mat3[300][300];
- for(int i = 0; i < red; i++) {
- int ok = 0;
- for(int j = 0; j < novi_koloni; j++) {
- if(mat2[i][j] == minimalen_element) {
- ok = 1;
- }
- }
- if(ok == 0) {
- for(int j = 0; j < novi_koloni; j++) {
- mat3[novi_redovi][j] = mat2[i][j];
- }
- novi_redovi++;
- }
- }
- for(int i = 0; i < novi_redovi; i++) {
- for(int j = 0; j < novi_koloni; j++) {
- printf("%d ", mat3[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