Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- void trojkaty(int start, int stop, int h) {
- int i, j, k = 2 * h - 2;
- for (i = 0; i < start - 1; i++) k--;
- // rzędy
- for (i = start - 1; i < stop; i++) {
- // spacje
- for (j = 0; j < k; j++) printf(" ");
- k = k - 1;
- // funkcja po lewej
- for (j = 0; j <= i; j++) {
- if (j == 0 || (i==stop-1 && (stop==h || stop==4 || stop==h-1))) printf("*");
- else printf(" ");
- }
- //funkcja po prawej
- for (int x = i; x >= 0; x--) {
- if (x == 0 || (i == stop - 1 && (stop == h || stop == 4 || stop==h-1))) printf("*");
- else printf(" ");
- }
- printf("\n");
- }
- }
- void P(int h) {
- int a = h*3;
- int i, j, k = 2 * a - 4;
- for (i = 1; i <= h+1; i++) {
- //spacje
- for (j = 0; j < k; j++) printf(" ");
- //
- for (j = 1; j <= h+1; j++) printf("#");
- printf("\n");
- }
- }
- void D(int h) {
- int a;
- a = h * 3;
- int start = 1, stop = 0, roz = 3;
- for (stop=start+roz;stop<a+1;stop=start+roz) {
- trojkaty(start, stop, a);
- roz++;
- start = stop - start;
- }
- }
- int main() {
- int h;
- printf("Wysokosc drzwka?(minimum 3):");
- scanf("%d", &h);
- D(h);
- P(h);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement