
/** * 题目名称分段函数 p * 题目来源http://noi.openjudge.cn/ch0104/13/ p * 程序功能根据给定浮点数和分段函数输出对应的函数值 * * author 潘磊just_panleijust.edu.cn * version 1.0 */importjava.util.Scanner;publicclassMain{publicstaticvoidmain(String[]args){ScannerinputnewScanner(System.in);floatNinput.nextFloat();// 自变量浮点数本题需用单精度浮点数floatans;// 分段函数计算结果if(N5){// 如果0N5ans-N2.5F;}elseif(N10){// 否则如果5N10ans2-1.5F*(N-3)*(N-3);}else{// 否则10N20ansN/2-1.5F;}System.out.printf(%.3f,ans);}}