Program Java do wydrukowania postaci lub litera X za pomocą gwiazdy
import java.util.*;class Main{public static void main(String args[]){ int i,j,n;Scanner sc = new Scanner(System.in);System.out.println("Enter the number to print the character");n = sc.nextInt();for(i=n;i>=1;i--){for(j=i;j<n;j++){System.out.print(" ");}for(j=1;j<=(2*i-1);j++){if(j==1 || j==(2*i-1))System.out.print("*");elseSystem.out.print(" ");}System.out.println("");} for(i=2;i<=n;i++){for(j=i;j<n;j++){System.out.print(" ");}for(j=1;j<=(2*i-1);j++){if(j==1 || j==(2*i-1))System.out.print("*");elseSystem.out.print(" ");}System.out.println("");} }}
Helpless Hawk