Write a program to Print the V pattern using nested for and while loop
Note that : between two characters there is a tab.
Eg. for m=7, the output is written under.
Recognise the pattern and print the final output.
* *
* *
* *
*
Input Format
m will be given as an integer input
Constraints
3<=m<=2^31-1
Output Format
Print the pattern.
Sample Input 0
7
Sample Output 0
* *
* *
* *
*
Sample Input 1
5
Sample Output 1
* *
* *
*
Sample Input 2
9
Sample Output 2
* *
* *
* *
* *
*
Sample Input 3
11
Sample Output 3
* *
* *
* *
* *
* *
*
Sample Input 4
13
Sample Output 4
* *
* *
* *
* *
* *
* *
*
Also read: Dumroo pattern.
import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;
public class Solution {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int N = n;
for(int i=1; i<=(n/2)+1; i++){
for(int j=1; j<=i-1; j++){
System.out.print("\t");
}
for(int j=1; j<=1; j++){
System.out.print("*\t");
}
for(int j=1; j<=N-2; j++){
System.out.print("\t");
}N -= 2;
for(int j=1; j<=1; j++){
if(i!=( n/2)+1){
System.out.print("*\t");
}
}
System.out.println();
}
}
}