fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6. import java.util.Scanner;
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone
  9. {
  10. public static void main (String[] args) throws java.lang.Exception
  11. {
  12. // your code goes here
  13. Scanner l= new Scanner(System.in);
  14. int n= l.nextInt();
  15. // Создаем матрицу для хранения всех ответов
  16. int [][]x = new int [n][n];
  17. int m=(n-1)/2;
  18. for(int i=0;i<n;i++){
  19. for(int j=0;j<n;j++){
  20. x[i][j]=1;
  21. }
  22. for(int j=i+1;j<n-i-1;j++){
  23. x[i][j]=0;
  24. }
  25. }
  26.  
  27. for( int i=0;i<m;i++){
  28. for (int j=0;j<n;j++){
  29. if(x[i][j]==0) {
  30. x[n-i-1][j]=0;
  31. }
  32. }
  33. }
  34. for(int i=0;i<n;i++){
  35. for(int j=0;j<n;j++){
  36. if(x[i][j]!=0){
  37. System.out.print("*");
  38. }
  39. else System.out.print(" ");
  40. }
  41. System.out.println(" ");
  42. }
  43. }
  44. }
Success #stdin #stdout 0.12s 49324KB
stdin
7
stdout
*     * 
**   ** 
*** *** 
******* 
*** *** 
**   ** 
*     *