netjunky

KatjaJu

Oct 10th, 2010
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.46 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <math.h>
  4.  
  5. int main(int argc, char **argv) {
  6.     double A, B, H, X, Y;
  7.     int i = 0;
  8.    
  9.     printf("Y = ln( sqrt( e^(x - 1) ) ) tabuleerimine 1. meetodiga\n");
  10.    
  11.     printf("Enter A = ");
  12.     scanf("%lf", &A);
  13.    
  14.     printf("B = ");
  15.     scanf("%lf", &B);
  16.    
  17.     if( A > B ) {
  18.         do {
  19.             printf("H (H < 0) = ");
  20.             scanf("%lf", &H);
  21.         } while ( H > 0 );
  22.     } else {
  23.         do {
  24.             printf("H (H > 0) = ");
  25.             scanf("%lf", &H);
  26.         } while ( H < 0 );
  27.     }
  28.    
  29.     printf("  ARGUMENT  |  Funktsioon\n");
  30.     printf("__________________________\n");
  31.    
  32.     do {
  33.        
  34.         if( i == 0 ) {
  35.             X = A;
  36.         }
  37.        
  38.         if( X > B ) {
  39.             if ( i == 1 ) {
  40.                X = A + H;
  41.             }
  42.             if( i > 1 ) {
  43.                 X = A + i * H;
  44.             }
  45.         }
  46.            
  47.         if( X < B ) {
  48.             if( i == 1 ) {
  49.                 X = A + H;
  50.             }
  51.             if( i > 1 ) {
  52.                 X = A + i * H;
  53.             }
  54.         }
  55.        
  56.         Y = log( sqrt( exp( (double)(X - 1) ) ) );
  57.        
  58.         if( exp( X - 1 ) < 0 ) {
  59.             printf("Puudub\n");
  60.         } else {
  61.             printf("%10.4lf  |%10.4lf\n", X, Y);
  62.         }
  63.        
  64.         if( X == B ) {
  65.             system("PAUSE");
  66.             return 0;
  67.         }
  68.        
  69.         i++;
  70.        
  71.     } while(1);
  72.    
  73.     system("PAUSE");
  74.     return 0;
  75. }
Add Comment
Please, Sign In to add comment