信息学奥赛一点通C++第一章答案

信息学奥赛一点通C++第一章答案

1000

#include <bits/stdc++.h>
using namespace std;
int main(){
    int a,b;
    cin>>a>>b;
    cout<<(a+b);
    return 0;
}

2060

#include <bits/stdc++.h>
using namespace std;
int main(){
    cout<<"Hello World!";
    return 0;
}

2061

#include <bits/stdc++.h>
using namespace std;
int main(){
    printf("%0.2f\n",(15.0+25.0)*(150.0/15.0*2.0)/2.0);
    return 0;
}

2062

#include <bits/stdc++.h>
using namespace std;
int main(){
    int x;
    cin>>x;
    cout<<x<<' '<<(x*10);
    return 0;
}

2063

#include <bits/stdc++.h>
using namespace std;
int main(){
    int s;
    s=(15*20-20*10)/10;
    cout<<s;
    return 0;
}

1001

#include <bits/stdc++.h>
using namespace std;
int main(){
    cout<<"Hello,World!";
    return 0;
}

1002

#include <bits/stdc++.h>
using namespace std;
int main(){
    int a,b,c;
    cin>>a>>b>>c;
    cout<<b;
    return 0;
}

1003

#include<iostream>
#include<iomanip>
using namespace std;
int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    cout<<setw(8)<<a<<' '<<setw(8)<<b<<' '<<setw(8)<<c;
    return 0;
}

:使用setw()函数需要设置头文件为#include ,iomanip的作用是对输入输出做一些操作。需要注意的是 setw(n)设置宽度,若是实际宽度大于被设置的,则setw函数此时失效。

1004

#include<bits/stdc++.h>
using namespace std;
int main(){
    char a;
    cin>>a;
    cout<<" "<<" "<<a<<endl;
    cout<<" "<<a<<a<<a<<endl;
    cout<<a<<a<<a<<a<<a<<endl;
    return 0;
}

1005

#include <bits/stdc++.h>
using namespace std;
int main(){
    int x,a,y,b;
    double z;
    cin>>x>>a>>y>>b;
    z=(b*y-a*x)/(b-a);
    cout<<fixed<<setprecision(2)<<z;
    return 0;
}

:setprecision()这个函数要调用头文件iomanip,有fixed在前面函数参数就是指小数点后有几位数。如果没有fixed在前则函数参数表示输出结果总共有几位数,其余的舍弃;但若参数<整数位数,结果则为指数形式输出。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值