Advertisement
Guest User

Untitled

a guest
Nov 24th, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<stdlib.h>
  3. #include<math.h>
  4. void trojkat(int a, int h)
  5. {
  6. for (int i = 0; i<h; i++) {
  7. float wynik = (float)(1 + a) / (float)h*(float)i; // (1+szer)/wys*i
  8. wynik = round(wynik);
  9. int ile = (int)wynik+1;
  10. if (ile % 2==0)
  11. ile += 1;
  12. int spacje = (a - ile) / 2;
  13. if (i < (h - 1))
  14. {
  15. for (int j = 0; j < spacje; j++)
  16. printf(".");
  17. for (int j = 0; j < ile; j++)
  18. printf("*");
  19. }
  20. if (i == (h - 1))
  21. {
  22. for (int x = 0; x < a; x++)
  23. {
  24. printf("*");
  25. }
  26. }
  27. printf("\n");
  28. }
  29. }
  30. }
  31. int main()
  32. {
  33. int a;
  34. int h;
  35. printf("podaj bok: ");
  36. scanf ("%d", &a);
  37. while(a%2==0)
  38. {
  39.  
  40. printf("podaj bok: ");
  41. scanf("%d", &a);
  42. }
  43. printf("podaj wysokosc: ");
  44. scanf ("%d", &h);
  45. trojkat(a,h);
  46. system("PAUSE");
  47.  
  48. return 0;
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement