SHARE
TWEET

Untitled

a guest Oct 21st, 2019 65 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. printf("Trojuhelnik #1:\n");
  2.    if((scanf(" %3[SU] %lf %lf %lf", str1, &a, &b, &c)) != 4){
  3.        printf("Nespravny vstup.\n");
  4.        return 1;
  5.    }
  6.    if(a<=0 || b<=0 || c<=0 || ( ( (strcmp(str1, type[0]))  != 0 ) && ( (strcmp(str1, type[1])) != 0 ) && ( (strcmp(str1, type[2])) != 0 ) ) ){
  7.        printf("Nespravny vstup.\n");
  8.        return 1;
  9.    }
  10.    else
  11.    {
  12.        if ( (strcmp(str1, type[0])) == 0 )
  13.    {
  14.         ua = acos( ( pow(a, 2) - pow(b, 2) - pow(c, 2) ) / (-2*b*c) );
  15.         ub = acos( ( pow(b, 2) - pow(a, 2) - pow(c, 2) ) / (-2*a*c) );
  16.         uc = acos( ( pow(c, 2) - pow(b, 2) - pow(a, 2) ) / (-2*b*a) );
  17.        
  18.  
  19.         if( ( (a+b-c) <= (DBL_EPSILON * 64 * a * b *c) ) || ( (b+c-a) <= (DBL_EPSILON * 64 * a * b *c) ) || ( (a+c-b) <= (DBL_EPSILON * 64 * a * b *c) ) /*|| ( (ua+ub+uc) > (M_PI+DBL_EPSILON*M_PI) )*/ ){
  20.        printf("Vstup netvori trojuhelnik.\n");
  21.        return 1;
  22.      }
  23.  
  24.    }
  25.    
  26.     if ( strcmp(str1, type[1]) == 0 )
  27.    {
  28.        if( fabs(b-180.0) < (DBL_EPSILON*180*b) ){
  29.            printf("Nespravny vstup.\n");
  30.            return 1;
  31.            //(fabs(p1-1.0) < (DBL_EPSILON*1000)
  32.        }
  33.  
  34.        al1 = b;
  35.        ub = al1*( (double)M_PI/ (double)180 ) ;
  36.        b = sqrt( pow(c, 2) + pow(a, 2) -2*c*a*cos(ub) );
  37.        ua = acos( ( pow(a, 2) - pow(b, 2) - pow(c, 2) ) / (-2*b*c) );
  38.        uc = acos( ( pow(c, 2) - pow(b, 2) - pow(a, 2) ) / (-2*b*a) );
  39.        
  40.        
  41.        if( ( (a+b-c) <= (DBL_EPSILON * 64 * a * b *c) ) || ( (b+c-a) <= (DBL_EPSILON * 64 * a * b *c) ) || ( (a+c-b) <= (DBL_EPSILON * 64 * a * b *c) ) /*|| ( (ua+ub+uc) > (M_PI+DBL_EPSILON*M_PI) )*/ )  {
  42.        printf("Vstup netvori trojuhelnik.\n");
  43.        
  44.        return 1;
  45.      }
  46.    }
  47.    if ( strcmp(str1, type[2]) == 0  )
  48.    {
  49.        if( ( fabs(a-180.0) <= (DBL_EPSILON*180*a) ) || ( fabs(c-180.0) <= (DBL_EPSILON*180*c) ) ){
  50.            printf("Nespravny vstup\n");
  51.            return 1;
  52.        }
  53.        if (( fabs(a+c-180.0) <= (DBL_EPSILON*180*a*c) ))
  54.        {
  55.            printf("Vstup netvori trojuhelnik.\n");
  56.        return 1;
  57.        }
  58.        
  59.        al1 = 180.0 - a - c;
  60.        be1 = a;
  61.        ga1 = c;      
  62.        ua = be1*( (double)M_PI/ (double)180);
  63.        uc = ga1*( (double)M_PI / (double)180);
  64.        ub = al1*( (double)M_PI / (double)180);
  65.        a = ( b*sin(ua) / sin(ub) );
  66.        c = ( b*sin(uc) / sin(ub) );
  67.  
  68.        if( ( (a+b-c) <= (DBL_EPSILON * 64 * a * b *c) ) || ( (b+c-a) <= (DBL_EPSILON * 64 * a * b *c) ) || ( (a+c-b) <= (DBL_EPSILON * 64 * a * b *c) ) /*|| ( (ua+ub+uc) > (M_PI+DBL_EPSILON*M_PI) ) */){
  69.        printf("Vstup netvori trojuhelnik.\n");
  70.        return 1;
  71.      }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top