Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- void rysuj(int);
- int bezwzgledna(int);
- using namespace std;
- int bezwzgledna(int a){
- if(a<0){
- a=-a;
- }
- return a;
- }
- void rysuj(int bok){
- int korekta=bok/2;
- //int korekta_wymiaru=1;
- if(bok%2==1){
- korekta=(bok-1)/2;
- //korekta_wymiaru=0;
- }
- for(int y=-(bok-1); y<(bok-1)+1; y++){
- for(int x=-(bok+korekta-1); x<(bok+korekta); x++){
- if(bezwzgledna(x+bok+korekta-1)==bezwzgledna(y) or bezwzgledna(x-bok-korekta+1)==bezwzgledna(y))
- {
- cout<<"*";
- }
- else if((bezwzgledna(y)==(bok-1)) and bezwzgledna(x)<=korekta)
- {
- cout<<"x";
- if(bok%2==0 and x==1){
- cout<<"\b";
- }
- }
- else if(bok%2==0 and x==1){
- cout<<"";
- }
- else
- {
- cout<<" ";
- }
- }
- cout<<endl;
- }
- }
- int main()
- {
- int bok=1;
- while(bok>0){
- cout<<"Podaj bok(0 konczy program): ";
- cin>>bok;
- bok=bezwzgledna(bok);
- rysuj(bok);
- }
- return 0;
- }
Add Comment
Please, Sign In to add comment