Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int ft_sum_arithm_seq(int a, int d, int n)
- {
- int a_n;
- a_n = a + d * (n - 1);
- return ((n * (a + a_n)) / 2);
- }
- void sastantua(int l)
- {
- int i;
- int j;
- int space_count;
- i = 1;
- while(i <= l)
- {
- j = 1;
- space_count = 0;
- //printf("(%d %d)\n", (3 + (l - 1) * 2) / 2, 3 + (i - 1) * 2);
- while (j <= space_count + 3 + (i - 1) * 2)
- {
- if (j <= (3 + (l - 1) * 2) / 2 - (3 + (i - 1) * 2) / 2)
- {
- printf(" ");
- space_count++;
- }
- else if (j == (3 + (l - 1) * 2) / 2 - (3 + (i - 1) * 2) / 2 + 1)
- {
- printf("/");
- }
- else if (j > (3 + (l - 1) * 2) / 2 - (3 + (i - 1) * 2) / 2 + 1 && j < space_count + 3 + (i - 1) * 2)
- {
- printf("*");
- }
- else if (j == space_count + 3 + (i - 1) * 2)
- {
- printf("\\");
- }
- //printf("(%d %d)", j, space_count + 3 + (i - 1) * 2);
- j++;
- }
- printf("\n");
- i++;
- }
- }
- int ft_get_height(int n)
- {
- int h;
- int i;
- int j;
- int last_floor_h;
- int ignore;
- h = 0;
- i = 1;
- last_floor_h = 2;
- ignore = 1;
- while (i++ <= n)
- {
- j = 1;
- while (j++ <= last_floor_h + 1 + ignore)
- h++;
- if (last_floor_h % 2 == 1)
- ignore++;
- last_floor_h++;
- printf("\n--- %d %d (%d)---", ignore, last_floor_h, h);
- }
- return (h);
- }
- int main()
- {
- sastantua(9);
- printf("%d", ft_get_height(4));
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement