Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- int main()
- {
- int length,hight;
- if(scanf("%d",&length)==1 && scanf("%d",&hight)==1 )
- {
- int plot=0;
- if(length==hight){
- scanf("%d",&plot);
- }
- if(length<=2 || length>=70)
- {
- fprintf(stderr,"Error: Vstup mimo interval!\n");
- return 101;
- }
- if(hight<=2 || hight>=70)
- {
- fprintf(stderr,"Error: Vstup mimo interval!\n");
- return 101;
- }
- if(length%2==0){
- fprintf(stderr,"Error: Sirka neni liche cislo!\n");
- return 102;
- }
- if(plot==hight || plot<0)
- {
- fprintf(stderr,"Error: Neplatna velikost plotu!\n");
- return 103;
- }
- //Strecha
- int i, space, k=0;
- for(i=1; i<=length/2; ++i, k=0)
- {
- for(space=0; space<=length/2 -i ; space++)
- {
- printf(" ");
- }
- while(k !=2*i)
- {
- if(k==0 || k==2*i-2 || space==length/2 -i || space==0)
- printf("X"); else printf(" ");
- ++k;
- }
- printf("\n");
- }
- //zbytek
- for (int i=1; i<=hight; i++) {
- for (int j=1; j<=length; j++) {
- if(hight==length)
- {
- if(j==length || j==1 || i==1 || i==hight) {
- printf("X");
- int k;
- if (j == length && i>=hight-plot+1) {
- if (plot % 2 == 0) {
- for (k = 0; k < plot; k++) {
- if(k%2!=0)
- {
- printf("|");
- } else if((k%2==0&&i==hight)||(k%2==0&&i==hight-plot+1))
- {
- printf("-");
- } else printf(" ");
- }
- //printf("\n");
- } else if(plot % 2!=0) {
- for (int u = 0; u < plot; u++) {
- if(u==0|| u%2==0){
- printf("|");
- } else if(i==hight-plot+1||i==hight)
- {
- printf("-");
- }
- else printf(" ");
- }
- }
- //printf("\n");
- }
- }else if((j%2==0 && i%2==0) || (j%2!=0 &&i%2!=0))
- {
- printf("o");
- } else printf("*");
- } else {
- if(j==length || j==1 || i==1 || i==hight)
- printf("X"); else printf(" ");
- }
- }
- printf("\n");
- }
- return 0;
- }else {
- int plot;
- if(scanf("%d",&plot)!=1){
- fprintf(stderr,"Error: Chybny vstup!\n");
- return 100;
- }
- fprintf(stderr,"Error: Chybny vstup!\n");
- return 100;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement