Advertisement
Guest User

Untitled

a guest
Oct 25th, 2016
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.52 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4.  
  5. int main()
  6. {
  7. int length,hight;
  8.  
  9.  
  10. if(scanf("%d",&length)==1 && scanf("%d",&hight)==1 )
  11.  
  12.  
  13. {
  14. int plot=0;
  15. if(length==hight){
  16.  
  17. scanf("%d",&plot);
  18.  
  19. }
  20.  
  21.  
  22.  
  23. if(length<=2 || length>=70)
  24. {
  25. fprintf(stderr,"Error: Vstup mimo interval!\n");
  26. return 101;
  27. }
  28.  
  29. if(hight<=2 || hight>=70)
  30. {
  31. fprintf(stderr,"Error: Vstup mimo interval!\n");
  32. return 101;
  33. }
  34. if(length%2==0){
  35. fprintf(stderr,"Error: Sirka neni liche cislo!\n");
  36. return 102;
  37. }
  38.  
  39. if(plot==hight || plot<0)
  40. {
  41. fprintf(stderr,"Error: Neplatna velikost plotu!\n");
  42. return 103;
  43. }
  44.  
  45. //Strecha
  46. int i, space, k=0;
  47.  
  48. for(i=1; i<=length/2; ++i, k=0)
  49. {
  50. for(space=0; space<=length/2 -i ; space++)
  51. {
  52. printf(" ");
  53. }
  54.  
  55. while(k !=2*i)
  56. {
  57. if(k==0 || k==2*i-2 || space==length/2 -i || space==0)
  58. printf("X"); else printf(" ");
  59.  
  60. ++k;
  61. }
  62.  
  63. printf("\n");
  64. }
  65.  
  66.  
  67. //zbytek
  68. for (int i=1; i<=hight; i++) {
  69.  
  70. for (int j=1; j<=length; j++) {
  71. if(hight==length)
  72. {
  73.  
  74. if(j==length || j==1 || i==1 || i==hight) {
  75. printf("X");
  76. int k;
  77. if (j == length && i>=hight-plot+1) {
  78.  
  79.  
  80. if (plot % 2 == 0) {
  81. for (k = 0; k < plot; k++) {
  82. if(k%2!=0)
  83. {
  84. printf("|");
  85. } else if((k%2==0&&i==hight)||(k%2==0&&i==hight-plot+1))
  86. {
  87. printf("-");
  88. } else printf(" ");
  89.  
  90.  
  91. }
  92. //printf("\n");
  93.  
  94. } else if(plot % 2!=0) {
  95. for (int u = 0; u < plot; u++) {
  96.  
  97. if(u==0|| u%2==0){
  98. printf("|");
  99. } else if(i==hight-plot+1||i==hight)
  100. {
  101. printf("-");
  102. }
  103.  
  104. else printf(" ");
  105. }
  106. }
  107. //printf("\n");
  108.  
  109.  
  110. }
  111.  
  112. }else if((j%2==0 && i%2==0) || (j%2!=0 &&i%2!=0))
  113. {
  114. printf("o");
  115. } else printf("*");
  116. } else {
  117. if(j==length || j==1 || i==1 || i==hight)
  118. printf("X"); else printf(" ");
  119. }
  120.  
  121.  
  122. }
  123. printf("\n");
  124.  
  125.  
  126. }
  127.  
  128.  
  129.  
  130.  
  131. return 0;
  132.  
  133. }else {
  134. int plot;
  135. if(scanf("%d",&plot)!=1){
  136. fprintf(stderr,"Error: Chybny vstup!\n");
  137. return 100;
  138. }
  139.  
  140. fprintf(stderr,"Error: Chybny vstup!\n");
  141. return 100;
  142.  
  143. }
  144.  
  145. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement