Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <math.h>
- #define DoWhile
- double ecuation(double x){
- double y,a = 1.5;
- if(x<1.3){
- y = M_PI*pow(x,2) - (7/pow(x,2));
- }
- else if(x == 1.3){
- y = a*x + 7*sqrt(x);
- }
- else{
- y = log(x+7*sqrt(x));
- }
- return y;
- }
- #ifdef For
- void ForRange(double begin, double end, double step){
- for(; begin <= end; begin +=step)
- printf( "%lf\n", ecuation(begin));
- }
- #endif
- #ifdef While
- void WhileRange(double begin, double end, double step){
- while( begin <= end){
- printf( "%lf\n", ecuation(begin));
- begin+=step;
- }
- }
- #endif
- #ifdef DoWhile
- void doWhileRange(double begin, double end , double step){
- do{
- printf( "%lf\n", ecuation(begin));
- begin+=step;
- }while( begin <= end);
- }
- #endif
- void scanData(double *begin,double* end, double *step){
- printf("Introduceti inceputul intervalului >");
- scanf("%lf", begin);
- printf("Introduceti sfarsitul intervalului >");
- scanf("%lf", end);
- printf("Introduceti pasul >");
- scanf("%lf", step);
- }
- int main()
- {
- double begin , end , step ;
- scanData(&begin,&end,&step);
- #ifdef For
- ForRange(begin,end,step);
- #endif
- #ifdef While
- WhileRange(begin,end,step);
- #endif
- #ifdef DoWhile
- doWhileRange(begin,end,step);
- #endif
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement