/**ProgramCopyright and version description Section * copyright (c) 2012, Yantai University Computer college student * All rightsreserved. * file name: Fun. CPP * Author: Qiu xuewei * Completion Date: July 15, November 17, 2012 * version: V1.0 * description of the task and solution * input Description: function independent variable X * Problem description: evaluate the function value: when x <0.3, f (x) = 0; When 0.3 ≤ x ≤ 0.8, f (x) = (x-0.3)/(0.8-0.3 ); when x> 0.8, f (x) = 1; * program output: F (x) value */# include <iostream> using namespace STD; const double X1 = 0.3, x2 = 0.8; // two constants are defined as global constant variables, which is convenient and easy to maintain. Double F (double); // declare int main () {int X; cout <"Enter the value of X:" <Endl; CIN> X; cout <"solution: f (x) =" <F (x) <"\ n"; return 0;} double F (Double X) {double F; // you need to define the custom variable if (x <X1) f = 0; else if (x <= x2) F = (x-x1)/(x2-x1); elsef = 1; return F ;}