Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<stdlib.h>
- #include<math.h>
- void trojkat(int a, int h)
- {
- for (int i = 0; i<h; i++) {
- float wynik = (float)(1 + a) / (float)h*(float)i; // (1+szer)/wys*i
- wynik = round(wynik);
- int ile = (int)wynik+1;
- if (ile % 2==0)
- ile += 1;
- int spacje = (a - ile) / 2;
- if (i < (h - 1))
- {
- for (int j = 0; j < spacje; j++)
- printf(".");
- for (int j = 0; j < ile; j++)
- printf("*");
- }
- if (i == (h - 1))
- {
- for (int x = 0; x < a; x++)
- {
- printf("*");
- }
- }
- printf("\n");
- }
- }
- }
- int main()
- {
- int a;
- int h;
- printf("podaj bok: ");
- scanf ("%d", &a);
- while(a%2==0)
- {
- printf("podaj bok: ");
- scanf("%d", &a);
- }
- printf("podaj wysokosc: ");
- scanf ("%d", &h);
- trojkat(a,h);
- system("PAUSE");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement