Guest User

Untitled

a guest
Jan 19th, 2019
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.63 KB | None | 0 0
  1. /*
  2. * File: main.c
  3. * Author: hilda
  4. *
  5. * Created on 14 10 2012 г., 23:25
  6. */
  7.  
  8. #include <stdio.h>
  9. #include <stdlib.h>
  10. #include <math.h>
  11.  
  12. /*
  13. *
  14. */
  15. int main(int argc, char** argv) {
  16. double prom = 0.001;
  17. double a1, b1, c1, a2, b2, c2;
  18. int res_scan1, res_scan2;
  19.  
  20. printf("Zadejte velikost stran prveho trojuhelniku:\n");
  21. res_scan1 = scanf("%lf%lf%lf", &a1, &b1, &c1);
  22.  
  23. if ((res_scan1 != 3) || (a1 <= 0) || (b1 <= 0) || (c1 <= 0) ||
  24. !((a1 + b1 > c1) && (a1 + c1 > b1) && (c1 + b1 > a1))) {
  25. printf("Nespravny vstup.\n");
  26. return 0;
  27. }
  28.  
  29. printf("Zadejte velikost stran druheho trojuhelniku:\n");
  30. res_scan2 = scanf("%lf%lf%lf", &a2, &b2, &c2);
  31.  
  32. if ((res_scan2 != 3) || (a2 <= 0) || (b2 <= 0) || (c2 <= 0) ||
  33. !((a2 + b2 > c2) && (a2 + c2 > b2) && (c2 + b2 > a2))) {
  34. printf("Nespravny vstup.\n");
  35. return 0;
  36. }
  37.  
  38. if (((fabs(a1*1.0/a2 - b1*1.0/b2) < prom) && (fabs(a1*1.0/a2 - c1*1.0/c2) < prom))
  39. || ((fabs(a1*1.0/b2 - b1*1.0/a2) < prom) && (fabs(a1*1.0/b2 - c1*1.0/c2) < prom))
  40. || ((fabs(a1*1.0/b2 - b1*1.0/c2) < prom) && (fabs(a1*1.0/b2 - c1*1.0/a2) < prom))
  41. || ((fabs(a1*1.0/c2 - b1*1.0/a2) < prom) && (fabs(a1*1.0/c2 - c1*1.0/b2) < prom))
  42. || ((fabs(a1*1.0/c2 - b1*1.0/b2) < prom) && (fabs(a1*1.0/c2 - c1*1.0/a2) < prom))
  43. || ((fabs(a1*1.0/a2 - b1*1.0/c2) < prom) && (fabs(a1*1.0/a2 - c1*1.0/b2) < prom))) {
  44. printf("Trojuhelniky jsou podobne.\n");
  45. } else {
  46. printf("Trojuhelniky nejsou podobne.\n");
  47. }
  48.  
  49. return 0;
  50. }
Add Comment
Please, Sign In to add comment