Exercise 2-10 Measurements of Function [1] (10 minutes)

Exercise 2-10 Measurements of Function [1] (10 minutes)

The title calculate the following claims piecewise function F ( X value):

Input formats:

Input gives the real number x in a row.

Output formats:

In a row by "f (x) = result" output format, wherein both x and result to one decimal place.

Sample Input 1:

10

Output Sample 1:

f(10.0) = 0.1

Sample Input 2:

0

Output Sample 2:

f(0.0) = 0.0

 

#include <stdio.h>
#include <stdlib.h>

/* run this program using the console pauser or add your own getch, system("pause") or input loop */

int main(int argc, char *argv[]) {
double
x,f;
scanf("%lf",&x);
if (x==0){
f=0;}

else{
f=1/x;}

printf("f(%.1f) = %.1f",x,f);

return 0;
}

 

 

Guess you like

Origin www.cnblogs.com/xxl-h/p/11110837.html