# Horor_CPP_Done

Sep 16th, 2023 (edited)
802
0
349 days
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. #include <stdio.h>
2. #include <stdlib.h>
3. #include <math.h>
4.
5. #define DoWhile
6. double ecuation(double x){
7.
8.     double y,a = 1.5;
9.
10.     if(x<1.3){
11.         y = M_PI*pow(x,2) - (7/pow(x,2));
12.     }
13.     else if(x == 1.3){
14.         y = a*x + 7*sqrt(x);
15.     }
16.     else{
17.         y = log(x+7*sqrt(x));
18.     }
19.     return y;
20. }
21.
22. #ifdef For
23.     void ForRange(double begin, double end, double step){
24.         for(; begin <= end; begin +=step)
25.             printf( "%lf\n", ecuation(begin));
26.     }
27. #endif
28.
29. #ifdef While
30.     void WhileRange(double begin, double end, double step){
31.         while( begin <= end){
32.             printf( "%lf\n", ecuation(begin));
33.             begin+=step;
34.         }
35.     }
36. #endif
37.
38. #ifdef DoWhile
39.     void doWhileRange(double begin, double end ,  double step){
40.         do{
41.             printf( "%lf\n", ecuation(begin));
42.             begin+=step;
43.         }while( begin <= end);
44.     }
45. #endif
46.
47. void scanData(double *begin,double* end, double *step){
48.     printf("Introduceti inceputul intervalului >");
49.     scanf("%lf", begin);
50.     printf("Introduceti sfarsitul intervalului >");
51.     scanf("%lf", end);
52.     printf("Introduceti pasul >");
53.     scanf("%lf", step);
54. }
55.
56. int main()
57. {
58.     double begin , end , step ;
59.
60.     scanData(&begin,&end,&step);
61.
62.     #ifdef For
63.         ForRange(begin,end,step);
64.     #endif
65.
66.     #ifdef While
67.         WhileRange(begin,end,step);
68.     #endif
69.
70.     #ifdef DoWhile
71.         doWhileRange(begin,end,step);
72.     #endif
73.
74.     return 0;
75. }
76.