Advertisement
Guest User

Untitled

a guest
Jan 15th, 2019
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.05 KB | None | 0 0
  1. /******************************************************************************
  2.  
  3. Online C++ Compiler.
  4. Code, Compile, Run and Debug C++ program online.
  5. Write your code in this editor and press "Run" button to compile and execute it.
  6.  
  7. *******************************************************************************/
  8.  
  9. #include <stdio.h>
  10.  
  11. int main()
  12. {
  13. printf("Enter N: ");
  14. printf("\n");
  15. long n;
  16. scanf("%d", &n);
  17.  
  18. for (long i = 1; i <= n; i += 1) {
  19. for (long j = 0; j < n-i; j += 1) {
  20. printf(" ");
  21. }
  22.  
  23. if (i == 1 || i == n) {
  24. for (long j = 0; j < 2*i-1; j += 1) {
  25. printf("*");
  26. }
  27. } else {
  28. printf("*");
  29. for (long j = 0; j < (i-1)*2-1; j += 1) {
  30. printf("#");
  31. }
  32. printf("*");
  33. }
  34.  
  35. for (long j = 0; j < n-i; j += 1) {
  36. printf(" ");
  37. }
  38. printf("\n");
  39. }
  40.  
  41. return 0;
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement