Guest User

Untitled

a guest
Apr 20th, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.77 KB | None | 0 0
  1. #include <conio.h>
  2. #include <iostream.h>
  3. #include <stdio.h>
  4.  
  5.  
  6. int main ()
  7. {
  8.  int n,m,i,j,temp;
  9.  cout<<"n=";
  10.  cin>>n;
  11.  cout<<"\n";
  12.  char a[n][n];
  13.  setlocale (LC_CTYPE, ".1251");
  14.  
  15.  //Генерируем квадратный массив и выводим его
  16.  for(i=0; i<n; i++)
  17.  {
  18.           for(j=0; j<n; j++)
  19.                    {
  20.                    if(((j-(n-1)/2)*(j-(n-1)/2)+(i-(n-1)/2)*(i-(n-1)/2)<=(n-1)*(n-1)/4 && j>=(n/1/2)) || ((i<=j/2+(n-1)/2)&&(i>=-j/2+(n-1)/2)) && j<=(n-1)/2)
  21.                    a[i][j] = '*';
  22.                    else
  23.                    a[i][j] = ' ';
  24.                    }
  25.  }
  26.  
  27.  for(i=0; i<n; i++)
  28.  {
  29.           for(j=0; j<n; j++)
  30.                    cout<<a[i][j];
  31.           cout<<"\n";
  32.  }
  33.  
  34.  
  35.  getch ();
  36.  return 0;
  37. }
Add Comment
Please, Sign In to add comment