Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
2121 孙浚轩 11计算分段函数的值 C++ Compile Error 0 MS 0 KB 379 2023-12-16 12:00:59

Tests(0/0):


Code:

#include<iostream> #include<iomanip> using namespace std; int main() { double x,a=0; cin>>x; if(x>=0&&x<=20) { if(x<5) a=(-x+2.5); else if(x>=5&&x<10) a=(-5+2.5)+(2-1.5*((x-3)*2); else a=(-5+2.5)+(2-1.5*(5-3)*2)+(x/2-1.5); cout<<fixed<<setprecision(3)<<a; } return 0; }


Run Info:

Main.cc: In function 'int main()':
Main.cc:13:40: error: expected ')' before ';' token
             a=(-5+2.5)+(2-1.5*((x-3)*2);
                                        ^