Advertisement
BladeMechanics

Asterisk

Nov 20th, 2017
219
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.01 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<conio.h>
  3.  
  4. void descending(int height);
  5. void ascending(int height);
  6. void eks(int alt);
  7. void newline(int num);
  8.  
  9. void main()
  10. {
  11.     int number;
  12.     printf("\n\nEnter a number(desired height for figure):");
  13.     scanf_s("%d", &number);
  14.     descending(number);
  15.     newline(2);
  16.     ascending(number);
  17.     newline(2);
  18.     eks(number);
  19.     newline(2);
  20.     _getch();
  21. }
  22. void descending(int height)
  23. {
  24.     for (height; height; height--)
  25.     {
  26.         for (int i = height; i;i--) printf("*");
  27.         printf("\n");
  28.     }
  29. }
  30.  
  31. void ascending(int height)
  32. {
  33.     int row = 1, i;
  34.     for (row; row <= height; row++)
  35.     {
  36.         for (i = height - row; i; i--) printf(" ");
  37.         for (i = row; i;i--)printf("*");
  38.         printf("\n");
  39.     }
  40. }
  41.  
  42. void eks(int alt)
  43. {
  44.  
  45.     int row = 1;
  46.     for (int height = alt; height; height--)
  47.     {
  48.         for (int width = 1; width <= alt; width++)
  49.         {
  50.             if ((width == row) || (width == height)) printf("*");
  51.             else printf(" ");
  52.         }
  53.         printf("\n");
  54.         row++;
  55.     }
  56. }
  57.  
  58. void newline(int num)
  59. {
  60.     for (num; num; num--)
  61.         printf("\n");
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement