Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #define MAX 500
- int main()
- {
- int n, m;
- scanf("%d%d", &n, &m);
- int mat[MAX][MAX];
- 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 r[MAX][MAX];
- int ri = 0;
- for(int i = 0; i < n; i++) {
- int ima_barem_eden = 0;
- for(int j = 0; j < m; j++) {
- if(mat[i][j] == a || mat[i][j] == b || mat[i][j] == c) {
- ima_barem_eden = 1;
- }
- }
- if(ima_barem_eden == 1) {
- for(int j = 0; j < m; j++) {
- r[ri][j] = mat[i][j];
- }
- ri++;
- }
- }
- for(int i = 0; i < ri; i++) {
- for(int j = 0; j < m; j++) {
- printf("%d ", r[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