Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- big triangle v1.c
- In entered number_of_rows print triangle of *
- row spaces *
- 0. 4 1
- 1. 3 3
- 2. 2 5
- 3. 1 7
- 4. 0 9
- For number of spaces in a row we have to find relation with
- row and number_of_rows (number_of_rows - row - 1).
- For number of * in a row 2we have to find relation with row (2*row+1).
- */
- #include <stdio.h>
- int main(void)
- {
- int i, row, number_of_rows;
- printf("Triangle of how much number_of_rows = ");
- scanf("%d", &number_of_rows); // try 40
- printf("\n");
- for (row=0; row<number_of_rows; row++) // print rows one by one row
- {
- for (i=0; i<number_of_rows-row-1; i++) // print spaces, number_of_rows-row-1 times
- printf("-"); // replace "-" with " "
- for (i=0; i<2*row+1; i++) // print *, 2*row+1 times
- printf("*");
- printf("\n"); // new row
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment