Advertisement
WONGDEEM

Untitled

Jul 27th, 2019
167
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <cs50.h>
  2. #include <stdio.h>
  3.  
  4. int get_positive_int(string prompt) {
  5.     int positive_int;
  6.     do {
  7.         positive_int = get_int("%s",prompt);
  8.     } while (positive_int < 1 || positive_int > 8);
  9.     return positive_int;
  10. }
  11.  
  12. int main(void) {
  13.     int number_of_rows = get_positive_int("Height: ");
  14.     for (int i=0;i<number_of_rows;i++) {
  15.         for (int j=number_of_rows-i-1;j>0;j--) {
  16.             printf(" ");
  17.         }    
  18.         for (int k=0;k<i+1;k++) {
  19.             printf("#");
  20.         }
  21.         printf("\n");
  22.     }
  23. }
Advertisement
Advertisement
Advertisement
RAW Paste Data Copied
Advertisement