Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * File: main.c
- * Author: hilda
- *
- * Created on 14 10 2012 г., 23:25
- */
- #include <stdio.h>
- #include <stdlib.h>
- #include <math.h>
- /*
- *
- */
- int main(int argc, char** argv) {
- double prom = 0.001;
- double a1, b1, c1, a2, b2, c2;
- int res_scan1, res_scan2;
- printf("Zadejte velikost stran prveho trojuhelniku:\n");
- res_scan1 = scanf("%lf%lf%lf", &a1, &b1, &c1);
- if ((res_scan1 != 3) || (a1 <= 0) || (b1 <= 0) || (c1 <= 0) ||
- !((a1 + b1 > c1) && (a1 + c1 > b1) && (c1 + b1 > a1))) {
- printf("Nespravny vstup.\n");
- return 0;
- }
- printf("Zadejte velikost stran druheho trojuhelniku:\n");
- res_scan2 = scanf("%lf%lf%lf", &a2, &b2, &c2);
- if ((res_scan2 != 3) || (a2 <= 0) || (b2 <= 0) || (c2 <= 0) ||
- !((a2 + b2 > c2) && (a2 + c2 > b2) && (c2 + b2 > a2))) {
- printf("Nespravny vstup.\n");
- return 0;
- }
- if (((fabs(a1*1.0/a2 - b1*1.0/b2) < prom) && (fabs(a1*1.0/a2 - c1*1.0/c2) < prom))
- || ((fabs(a1*1.0/b2 - b1*1.0/a2) < prom) && (fabs(a1*1.0/b2 - c1*1.0/c2) < prom))
- || ((fabs(a1*1.0/b2 - b1*1.0/c2) < prom) && (fabs(a1*1.0/b2 - c1*1.0/a2) < prom))
- || ((fabs(a1*1.0/c2 - b1*1.0/a2) < prom) && (fabs(a1*1.0/c2 - c1*1.0/b2) < prom))
- || ((fabs(a1*1.0/c2 - b1*1.0/b2) < prom) && (fabs(a1*1.0/c2 - c1*1.0/a2) < prom))
- || ((fabs(a1*1.0/a2 - b1*1.0/c2) < prom) && (fabs(a1*1.0/a2 - c1*1.0/b2) < prom))) {
- printf("Trojuhelniky jsou podobne.\n");
- } else {
- printf("Trojuhelniky nejsou podobne.\n");
- }
- return 0;
- }
Add Comment
Please, Sign In to add comment