#include<iostream>
#include<iomanip>
using namespace std;
int main()
{
double pf,bn;
cin>>pf;
bn=0;
if(pf>0)
{
if(pf<100001)
bn=pf*0.1;
else if(pf>10000&&pf<200001)
bn=1e4+(pf-1e5)*0.075;
else if(pf>20000&&pf<400001)
bn=1e4+1e5*0.075+(pf-1e5*2)*0.05;
else if(pf>40000&&pf<600001)
bn=1e4+1e5*0.075+1e5*2*0.05+(pf-1e5*4)*0.03;
else if(pf>60000&&pf<1000001)
bn=1e4+1e5*0.075+1e5*2*(0.05+0.03)+(pf-1e5*6)*0.015;
else if(pf>1000000)
bn=1e4+1e5*0.075+1e5*2*(0.05+0.03)+1e5*4*0.015+(pf-1e6)*0.01;
}
cout<<fixed<<setprecision(2)<<bn;
return 0;
}
#include<iostream>
using namespace std;
int main()
{
int n,m,i,t1,t2,t;
cin>>n>>m;
int a[n];
for(i=0;i<n;i++)
{
cin>>a[i];
}
for(i=0;i<m;i++)
{
cin>>t1>>t2;
t=a[t1-1];
a[t1-1]=a[t2-1];
a[t2-1]=t;
}
for(i=0;i<n;i++)
cout<<a[i]<<endl;
return 0;
}
1543蓝桥杯算法提高VIP-淘淘的名单
#include<iostream>
#include<string>
using namespace std;
int main()
{
int n;
cin>>n;
string s;
for(int i=0;i<n;i++)
{
cin>>s;
if(s=="WYS")cout<<"KXZSMR"<<endl;
else if(s=="CQ")cout<<"CHAIQIANG"<<endl;
else if(s=="LC")cout<<"DRAGONNET"<<endl;
else if(s=="SYT"||s=="SSD"||s=="LSS"||s=="LYF")cout<<"STUDYFATHER"<<endl;
else cout<<"DENOMINATOR"<<endl;
}
return 0;
}
1509蓝桥杯算法提高VIP-图形输出
#include<iostream>
using namespace std;
int main()
{
cout<<" "<<"X"<<" "<<'|'<<" "<<"X"<<" "<<'|'<<" "<<"X"<<" "<<endl;
cout<<"---+---+---"<<endl;
cout<<" "<<" "<<" "<<'|'<<" "<<" "<<" "<<'|'<<" "<<" "<<" "<<endl;
cout<<"---+---+---"<<endl;
cout<<" "<<"O"<<" "<<'|'<<" "<<"O"<<" "<<'|'<<" "<<"O"<<" ";
return 0;
}
1504蓝桥杯算法提高VIP-勾股数
#include<iostream>
using namespace std;
int main()
{
int i,j,k;
for(i=1;i<1001;i++)
for(j=i;j<1001;j++)
for(k=j;k<1001;k++)
{
if(i+j+k<1001)
{
if(i*i+j*j==k*k)
cout<<i<<' '<<j<<' '<<k<<endl;
}
}
return 0;
}
#include<iostream>
#include<cstring>
using namespace std;
int main()
{
string s;
int t=0;
getline(cin,s);
for(int i=0;i<sizeof(s);i++)
{
if(s[i]==' ')
t++;
}
cout<<t+1;
return 0;
}
1480模拟计算器
#include<iostream>
using namespace std;
int main()
{
int a,b;
char c;
cin>>a>>b>>c;
switch(c)
{
case '+':cout<<a+b;break;
case '-':cout<<a-b;break;
case '*':cout<<a*b;break;
case '/':cout<<a/b;break;
case '%':cout<<a%b;break;
default:cout<<"error";
}
cout<<endl;
return 0;
}
1532蓝桥杯算法提高VIP-数组输出
#include<iostream>
using namespace std;
int main()
{
int a[3][4];
int Max,t,b;
for(int i=0;i<3;i++)
{
for(int j=0;j<4;j++)
cin>>a[i][j];
}
Max=a[0][0];t=0;b=0;
for(int i=0;i<3;i++)
{
for(int j=0;j<4;j++)
if(a[i][j]>0&&a[i][j]>Max)
{
Max=a[i][j];
t=i;
b=j;
}
else if(a[i][j]<0&&(-1*a[i][j])>Max)
{
Max=-1*a[i][j];
t=i;
b=j;
}
else if(a[i][j]==0&&a[i][j]>Max)
{
Max=a[i][j];
t=i;
b=j;
}
}
cout<<Max<<' '<<t+1<<' '<<b+1<<endl;
return 0;
}
1547蓝桥杯算法提高VIP-理财计划
我自己写的有一个测试没通过,贴一下这位同学的正确答案。
作者:蓝桥杯算法提高VIP-理财计划-题解(C++代码)-Dotcpp编程社区
#include<bits/stdc++.h>
using namespace std;
int main() {
int n, k, m;
double p, s = 0;
cin >> k >> n >> p; //每月存入款数、存储时长、利率
double b = k; //当前存款
while(n --){
s += b * p; //利息 = 存款 ×利率
b = b * p + b + k; //存款增多
}
s = floor(s * 100); //不四舍五入,仅保留两位小数
s = s / 100;
cout << s;
return 0;
}