wufangyuan @ 2024-06-29 19:24:31
求助,60分
by keep_shining @ 2024-06-29 19:48:23
@wufangyuan 你的代码
by keep_shining @ 2024-06-29 19:52:58
@wufangyuan
#include<bits/stdc++.h>
using namespace std;
#define fst ios::sync_with_stdio(false);cin.tie();cout.tie();
#define Endl endl
#define itn int
#define For(i,a,b) for(int i=a;i<=b;i++)
#define rep(i,a,b) for(int i=a;i>=b;i--)
const int N=1e5+5;
const int P=1e9+7;
int n;
int read()
{
int x=0,f=1;
char ch=getchar();
while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
while(ch>='0'&&ch<='9'){x=(x<<3)+(x<<1)+(ch^48);ch=getchar();}
return x*f;
}
void write(int x)
{
if(x<0)putchar('-'),x=-x;
if(x>9)write(x/10);
putchar(x%10+'0');
}
int main()
{
cin>>n;
if(n<=150)printf("%.1lf",n*0.4463);
else if(n<=400)printf("%.1lf",150*0.4463+(n-150)*0.4663);
else printf("%.1lf",150*0.4463+250*0.4663+(n-400)*0.5663);
return 0;
}
我直接给你我的代码吧
by tangyiqi @ 2024-07-09 17:17:01
@wufangyuan
我没实力,但我可以保证我的代码比楼上(下)好一点点(不是“亿”),给朋友看会显得你比较帅,会很多东西
#include <bits/stdc++.h>
using namespace std;
int a;
double price = 0.0;
double dian1(int x);
double dian2(int x);
double dian3(int x);
void print(double x);
int main(){
scanf("%d",&a);
if(a<=150)print(dian1(a));
else if(a>150 && a<=400)print(dian2(a));
else print(dian3(a));
return 0;
}
double dian1(int x){
price+=x*1.0*0.4463;
return price;
}
double dian2(int x){
price+=1.0*0.4463*150+(x-150)*1.0*0.4663;
return price;
}
double dian3(int x){
price+=1.0*0.4463*150+(400-150)*1.0*0.4663+(x-400)*1.0*0.5663;
return price;
}
void print(double x){
printf("%.1lf",x);
return;
}