Compile Error求助

B2047 分段函数

simple_child @ 2024-05-23 08:58:58

#include<bits/stdc++.h>
using namespace std;
int main()
{
    double x;
    cin>>x;
    if(0<=x && x<5) cout<<fixed<<setprecision(3)<<-x+2.5<<endl;
    else if(5<=x && x<10) cout<<fixed<<setprecision(3)<<2−1.5(x−3)(x−3)<<endl;
    else if(10<=x && x<20) cout<<fixed<<setprecision(3)<<x/2−1.5<<endl;
    return 0;
}

by __Emerald__ @ 2024-05-23 09:23:20

#include<bits/stdc++.h>
using namespace std;
int main()
{
    double x;
    cin>>x;
    if(0<=x && x<5) printf("%.3lf",-x+2.5);
    else if(5<=x && x<10) printf("%.3lf",2-1.5*(x-3)*(x-3));
    else if(10<=x && x<20) printf("%.3lf",x/2-1.5);
    return 0;
}

by __Emerald__ @ 2024-05-23 09:23:44

@simple_child


by simple_child @ 2024-05-23 09:26:15

@Zoe_888 哦哦,看到了,忘*了


by Special_Tony @ 2024-05-23 11:11:43

@simple_child 要用半角(英文)符号,而且c++中要乘号


by simple_child @ 2024-05-24 09:01:16

@Special_Tony 是半角啊,乘号加了还wa


by simple_child @ 2024-05-24 09:02:34

@Special_Tony 乘号加了还编译错


by simple_child @ 2024-05-24 09:31:11

@Special_Tony 发现问题了,-错了


by simple_child @ 2024-05-24 09:31:37

@Special_Tony -打成—了


by simple_child @ 2024-05-24 09:34:23

AC了无需回复了


|