Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main()
- {
- string napis;
- int pomocnicza;
- int ile,ile2,liczba;
- while(true)
- {
- cin>>ile2;
- ile=abs(ile2);
- pomocnicza=2*ile-1;
- if (ile2==0)
- {
- exit(0);
- }
- else if (ile2<0)
- {
- for(int i=0; i<=pomocnicza; i++)
- {
- napis="";
- for(int j=0; j<=pomocnicza; j++)
- {
- if(i==j)
- {
- napis+="*";
- }
- else if(i==(pomocnicza-j))
- {
- napis+="*";
- }
- else if ((i<j)&&(j<=(pomocnicza/2)))
- {
- napis+="*"; //Obszar 1
- }
- else if ( ((i+j)>pomocnicza) && (i<=(pomocnicza/2)) &&(j>=ile) )
- {
- napis+="*"; //Obszar 3
- }
- else if ((i>j)&&(j>=ile))
- {
- napis+="*"; //Obszar 5
- }
- else if( ((i+j)<pomocnicza) && (i>=ile) && (j<=(pomocnicza/2)) )
- {
- napis+="*"; //Obszar 7
- }
- else
- {
- napis+=".";
- }
- }
- cout<<napis<<endl;
- }
- }
- else
- {
- for(int i=0; i<=pomocnicza; i++)
- {
- napis="";
- for(int j=0; j<=pomocnicza; j++)
- {
- if(i==j)
- {
- napis+="*";
- }
- else if(i==(pomocnicza-j))
- {
- napis+="*";
- }
- else if ( ((i+j)<pomocnicza) && (i<=(pomocnicza/2)) &&(j>=ile) )
- {
- napis+="*"; //Obszar 2
- }
- else if ( (i<j) && (i>=ile) && (j>=ile) )
- {
- napis+="*"; //Obszar 4
- }
- else if ( (j<(pomocnicza/2)) && ((i+j)>pomocnicza) )
- {
- napis+="*"; //Obszar 6
- }
- else if( (i<=(pomocnicza/2)) && (j<=(pomocnicza/2)) && i>j )
- {
- napis+="*"; // Obszar 8
- }
- else
- {
- napis+=".";
- }
- }
- cout<<napis<<endl;
- }
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement