Print Integer if Below is Odd
JAVA Code :-
import java.util.*;
public class Hello {
public static void main(String[] args) {
//Your Code Here
Scanner s=new Scanner(System.in);
int n,m;
n=s.nextInt();
m=s.nextInt();
int a[][]=new int[n][m];
int b[][]=new int[n][m];
for(int i=0;i<n;i++)
for(int j=0;j<m;j++)
a[i][j]=s.nextInt();
for(int j=0;j<m;j++)
{
for(int i=0;i<n-1;i++)
{
if(a[i+1][j]%2!=0)
{
b[i][j]=a[i][j];
}
}
}
for(int i=0;i<n;i++)
{
for(int j=0;j<m;j++)
{
if(b[i][j]==0)
System.out.print('*'+" ");
else
System.out.print(b[i][j]+" ");
}
System.out.println();
}
}
}
public class Hello {
public static void main(String[] args) {
//Your Code Here
Scanner s=new Scanner(System.in);
int n,m;
n=s.nextInt();
m=s.nextInt();
int a[][]=new int[n][m];
int b[][]=new int[n][m];
for(int i=0;i<n;i++)
for(int j=0;j<m;j++)
a[i][j]=s.nextInt();
for(int j=0;j<m;j++)
{
for(int i=0;i<n-1;i++)
{
if(a[i+1][j]%2!=0)
{
b[i][j]=a[i][j];
}
}
}
for(int i=0;i<n;i++)
{
for(int j=0;j<m;j++)
{
if(b[i][j]==0)
System.out.print('*'+" ");
else
System.out.print(b[i][j]+" ");
}
System.out.println();
}
}
}
Comments
Post a Comment