蓝桥入门训练系列

蓝桥入门训练系列

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

试题 入门训练 A+B问题

#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;
}

原文链接: https://www.cnblogs.com/hyong-bingbing/p/12369085.html

欢迎关注

微信关注下方公众号,第一时间获取干货硬货;公众号内回复【pdf】免费获取数百本计算机经典书籍;

也有高质量的技术群,里面有嵌入式、搜广推等BAT大佬

    蓝桥入门训练系列

原创文章受到原创版权保护。转载请注明出处:https://www.ccppcoding.com/archives/332074

非原创文章文中已经注明原地址,如有侵权,联系删除

关注公众号【高性能架构探索】,第一时间获取最新文章

转载文章受原作者版权保护。转载请注明原作者出处!

(0)
上一篇 2023年3月1日 下午6:20
下一篇 2023年3月1日 下午6:20

相关推荐