Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int main() {
- int n, m;
- scanf("%d%d", &n, &m);
- int mat[n][m];
- for(int i = 0; i < n; i++) {
- for(int j = 0; j < m; j++) {
- scanf("%d", &mat[i][j]);
- }
- }
- int a, b, c;
- scanf("%d%d%d", &a, &b, &c);
- int redovi = 0;
- int mat2[n][m];
- for(int i = 0; i < n; i++) {
- int dali_ima_nekoj_od_broevite = -1;
- for(int j = 0; j < m; j++) {
- if(mat[i][j] == a || mat[i][j] == b || mat[i][j] == c) {
- dali_ima_nekoj_od_broevite = 1;
- }
- }
- if(dali_ima_nekoj_od_broevite == 1) {
- for(int j = 0; j < m; j++) {
- mat2[redovi][j] = mat[i][j];
- }
- redovi++;
- }
- }
- printf("\n");
- for(int i = 0; i <redovi; i++) {
- for(int j = 0; j < m; j++) {
- printf("%d ", mat2[i][j]);
- }
- printf("\n");
- }
- return 0;
- }
- /*
- 5 4
- 1 2 5 0
- 7 2 3 1
- 12 0 5 4
- 6 1 0 1
- 2 3 4 5
- 1 7 15
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement