蓝桥入门训练系列

用于熟悉蓝桥杯输入输出的一些水题。提供个人解法让各位没直接通过的同学参考一下

试题 入门训练 A+B问题

SRE实战 互联网时代守护先锋,助力企业售后服务体系运筹帷幄!一键直达领取阿里云限量特价优惠。
#include<iostream>
using namespace std;
int main(){
    int a,b;
    cin>>a>>b;
    cout<<a+b<<endl;
    return 0;
}

试题 入门训练 序列求和

#include<iostream>
using namespace std;
int main(){
    long long n;
    cin>>n;
    n=(1+n)*n/2;
    cout<<n;
    return 0;
}

试题 入门训练 圆的面积

#include<cstdio>
#include<iostream>
#define _USE_MATH_DEFINES
#include<math.h>
using namespace std;
int main(){
    int r=0;
    double area=0;
    cin>>r;
    area=M_PI*pow(r,2);
    printf("%.7f",area);
    return 0; 
}

试题 入门训练 Fibonacci数列

#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int main(){
    int a=1,b=1,n=0,temp=0;
    cin>>n;
    if(n==1||n==2){
        cout<<1<<endl;
        return 0;
    } 
    while(n>2){
        temp=(a+b)%10007;
        swap(a,b);
        swap(b,temp);
        n--;
    }
    cout<<b<<endl;
    return 0;
}
扫码关注我们
微信号:SRE实战
拒绝背锅 运筹帷幄