Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdlib.h>
- #include <stdio.h>
- #include <math.h>
- #define CUBE(X) (X)*(X)*(X)
- #define SQUARE(X) (X)*(X)
- const char * __out_format = "%0.3f \t %0.3f \n";
- float calc_func_value( float x )
- {
- if( x > 2 ) {
- return tanf( (CUBE(x) - 1) * 0.5 ) + sqrtf(x);
- }
- if ( x > 0 && x <= 2 ) {
- return logf(2.0/3.0 * x) - sinf(0.5 * x );
- }
- return expf(-1*x) + 2 * SQUARE(x);
- }
- void print_table(){
- float start = -3.0F;
- float step = 0.3F;
- float end = 4.0F;
- printf("x \t z \n");
- for(float x = start ; x < end; x += step ){
- float z = calc_func_value(x);
- printf(__out_format, x, z);
- }
- }
- int main( int __argc, char ** __argv ) {
- print_table();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement