Advertisement
HristoBaychev

7shape

Oct 5th, 2021 (edited)
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.34 KB | None | 0 0
  1.  
  2. #include <stdio.h>
  3.  
  4. void selectA() {
  5.     for (int i = 0; i < 6; i++) {
  6.         int y = 0;
  7.         while (y < i * 2) {
  8.             printf("  ");
  9.             y+=2;
  10.         }
  11.         for (y; y < 22-(i * 2); y++) {
  12.             printf("%c", y % 2 ? '#' : ' ');
  13.         }
  14.         printf("\n");
  15.     }
  16. }
  17.  
  18. void selectB() {
  19.     for (int i = 6; i > 0; i--) {
  20.         int y = 0;
  21.         while (y < i * 2-2) {
  22.             printf("  ");
  23.             y+=2;
  24.         }
  25.         for (y; y <= 24-(i * 2); y++) {
  26.             printf("%c", y % 2 ? '#' : ' ');
  27.         }
  28.         printf("\n");
  29.     }
  30. }
  31.  
  32. void selectC() {
  33.     for (int i = 6; i > 0; i--) {
  34.         int y = 0;
  35.         while (y < i * 2) {
  36.             printf("  ");
  37.             y+=2;
  38.         }
  39.         for (y; y < 22-(i * 2); y++) {
  40.             printf("%c", y % 2 ? '#' : ' ');
  41.         }
  42.         printf("\n");
  43.     }
  44.     for (int i = 0; i < 6; i++) {
  45.         int y = 0;
  46.         while (y < i * 2) {
  47.             printf("  ");
  48.             y+=2;
  49.         }
  50.         for (y; y < 22-(i * 2); y++) {
  51.             printf("%c", y % 2 ? '#' : ' ');
  52.         }
  53.         printf("\n");
  54.     }
  55. }
  56.  
  57. int main() {
  58.  
  59.     selectA();
  60.     printf("\n--------------------------------------------\n");
  61.     selectB();
  62.     printf("\n--------------------------------------------\n");
  63.     selectC();
  64.    return 0;
  65. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement