A_little_Jerry @ 2023-06-05 19:29:52
#include <bits/stdc++.h>
using namespace std;
main()
{
float sum1 , sum2;
cin >> sum1;
if (sum1 <= 150)
{
sum2 = 0.4463 * sum1; //用电量在150千瓦及以下部分按每千瓦时 0.4463元计算
}
else
{
if (sum1 <= 400)
{
sum2 = 0.4663 * sum1;//用电量在151∼400 千瓦时的部分按每千瓦时0.4663元计算
}
else
{
sum2 = 0.5663 * sum1;//用电量在401千瓦时及以上部分按每千瓦时0.5663元计算
}
}
printf("%.1lf \n",sum2);
return 0;
}
by WA_sir @ 2023-06-05 19:32:05
@A_little_Jerry 好好读题
by A_little_Jerry @ 2023-06-05 19:49:27
@WA_sir 感谢大佬,蒟蒻已更正 ;)
#include <bits/stdc++.h>
using namespace std;
int main()
{
double s , m ;
cin >> s;
if (s <= 150)
{
m = s * 0.4463;
}
if (s > 150)
{
if (s <= 400)
{
m = 150 * 0.4463 + ((s - 150) *0.4663);
}
}
if (s > 400)
{
m = 150 * 0.4463 + 250 * 0.4663 + ((s - 400) * 0.5663);
}
printf("%.1lf \n",m);
return 0;
}
by sy2023mdy @ 2023-07-09 15:55:57
SO,对没对?
by sy2023mdy @ 2023-07-09 15:56:56
我对C语言一窍不通