资深守护
题目链接: 酷町堂:2700
错误代码
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int main(){
double x,s,sum=0;
cin>>x>>s;
if(x==1){
if(s<=2.5){
sum=8;
}
else if(s<=15){
sum=8+(s-2.5)*1.4;
}
else{
sum=8+(s=2.5)*2.1;
}
}
else if(x==2){
if(s<=2.5){
sum=9;
}
else if(s<=15){
sum=9+(s-2.5)*1.4;
}
else{
sum=9+(s=2.5)*2.1;
}
}
int lc=(int)(sum+0.5);
cout<<lc;
return 0;
}
初级天翼
最后一个判断改成:
if(x==2){
if(s<=2.5)sum=9;
else if(s<=15)sum=9+(s-2.5)*1.4;
else sum=9+12.5*1.4+(s-15)*2.1;
}
实在不行把lc变成整型变量
缔造者
if(x==1) { if(s<=2.5) sum=8; else if(s<=15) sum=8+(s-2.5)*1.4; else sum=8+12.5*1.4+(s-15)*2.1; } if(x==2) { if(s<=2.5) sum=9; else if(s<=15) sum=9+(s-2.5)*1.4; else sum=9+12.5*1.4+(s-15)*2.1; } a=int(sum+0.5); cout<<a;