Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.*;
- import java.lang.*;
- import java.io.*;
- public class Main {
- public static void main (String[] args) throws java.lang.Exception {
- //your code here
- Scanner sc = new Scanner(System.in);
- int n = sc.nextInt();
- int m = sc.nextInt();
- int matrix[][] = new int[n][m];
- for (int i = 0; i < n; i++) {
- for (int j = 0; j < m; j++) {
- matrix[i][j] = sc.nextInt();
- }
- }
- //matrix=bool_mat(matrix, n, m);
- for (int i = 0; i < n; i++) {
- for (int j = 0; j < m; j++) {
- if (matrix[i][j] == 1) {
- for (j = 0; j < m; j++) {
- matrix[i][j] = 1;
- }
- }
- }
- }
- for (int i = 0; i < n; i++) {
- for (int j = 0; j < m; j++) {
- System.out.print(matrix[i][j] + " ");
- }
- System.out.println();
- }
- }
- static int[][] bool_mat(int matrix[][], int n, int m) {
- for (int i = 0; i < n; i++) {
- for (int j = 0; j < m; j++) {
- if (matrix[i][j] == 1) {
- for (j = 0; j < m; j++) {
- matrix[i][j] = 1;
- }
- break;
- }
- }
- }
- //display
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement