Guest User

Untitled

a guest
May 21st, 2018
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.93 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. void rysuj(int);
  4. int bezwzgledna(int);
  5. using namespace std;
  6.  
  7. int bezwzgledna(int a){
  8.     if(a<0){
  9.         a=-a;
  10.     }
  11.     return a;
  12. }
  13.  
  14. void rysuj(int bok){
  15.     for(int y=-(bok-1); y<(bok-1)+1; y++){
  16.         for(int x=-(bok+((bok-1)/2)-1); x<(bok+((bok-1)/2)-1)+1; x++){
  17.             if(bezwzgledna((x+bok+((bok-1)/2))-1)==bezwzgledna(y) or bezwzgledna(x-bok-((bok-1)/2)+1)==bezwzgledna(y))
  18.             {
  19.                 cout<<"*";
  20.             }
  21.             else if((bezwzgledna(y)==(bok-1)) and bezwzgledna(x)<=((bok-1)/2))
  22.             {
  23.                 cout<<"*";
  24.             }
  25.             else
  26.             {
  27.                 cout<<" ";
  28.             }
  29.         }
  30.         cout<<endl;
  31.     }
  32.  
  33. }
  34.  
  35. int main()
  36. {
  37.     int bok;
  38.     cout<<"Podaj bok(dls wartosci parzystej przyjeta zostanie o 1 mniejsza): ";
  39.     cin>>bok;
  40.     if(bok%2==0){
  41.         bok==bok-1;
  42.     }
  43.     rysuj(bok);
  44.     return 0;
  45. }
Add Comment
Please, Sign In to add comment