偶然乘兴,步过东冈。正莺儿啼,燕儿舞,蝶儿忙
文章目录
- [B2002 Hello,World!](https://www.luogu.com.cn/problem/B2002)
- [B2025 输出字符菱形](https://www.luogu.com.cn/problem/B2025)
- [P1000 超级玛丽游戏](https://www.luogu.com.cn/problem/P1000)
- [P1001 A+B Problem](https://www.luogu.com.cn/problem/P1001)
- [B2005 字符三角形](https://www.luogu.com.cn/problem/B2005)
- [P5703 【深基2.例5】苹果采购](https://www.luogu.com.cn/problem/P5703)
- [P5704 【深基2.例6】字母转换](https://www.luogu.com.cn/problem/P5704)
- [P5705 【深基2.例7】数字反转](https://www.luogu.com.cn/problem/P5705)
- [P5706 【深基2.例8】再分肥宅水](https://www.luogu.com.cn/problem/P5706)
- [P5708 【深基2.习2】三角形面积](https://www.luogu.com.cn/problem/P5708)
- [P5707 【深基2.例12】上学迟到](https://www.luogu.com.cn/problem/P5707)
- [B2029 大象喝水](https://www.luogu.com.cn/problem/B2029)
- [P1425 小鱼的游泳时间](https://www.luogu.com.cn/problem/P1425)
- [P1421 小玉买文具](https://www.luogu.com.cn/problem/P1421)
- [P3954 [NOIP 2017 普及组] 成绩](https://www.luogu.com.cn/problem/P3954)
B2002 Hello,World!
代码如下:
#include<iostream>
using namespace std;
int main(){
cout << "Hello,World!"<<endl;
return 0;
}
B2025 输出字符菱形
代码如下:
#include<iostream>
#include<string>
using namespace std;
int main(){
cout <<" *"<<endl;
cout <<" ***"<<endl;
cout <<"*****"<<endl;
cout <<" ***"<<endl;
cout <<" *"<<endl;
}
P1000 超级玛丽游戏
代码如下:
#include<iostream>
using namespace std;
int main()
{
cout<<R"( ********
************
####....#.
#..###.....##....
###.......###### ### ###
........... #...# #...#
##*####### #.#.# #.#.#
####*******###### #.#.# #.#.#
...#***.****.*###.... #...# #...#
....**********##..... ### ###
....**** *****....
#### ####
###### ######
##############################################################
#...#......#.##...#......#.##...#......#.##------------------#
###########################################------------------#
#..#....#....##..#....#....##..#....#....#####################
########################################## #----------#
#.....#......##.....#......##.....#......# #----------#
########################################## #----------#
#.#..#....#..##.#..#....#..##.#..#....#..# #----------#
########################################## ############ )";
}
P1001 A+B Problem
代码如下:
#include<iostream>
using namespace std;
int main(){
int a,b;
cin >> a >> b;
cout << a+b;
}
B2005 字符三角形
代码如下:
#include<iostream>
using namespace std;
int main(){
string a;
cin >> a;
cout <<" "<< a <<endl;
cout <<" "<< a << a << a <<endl;
cout << a << a << a << a << a <<endl;
}
P5703 【深基2.例5】苹果采购
代码如下:
#include<iostream>
using namespace std;
int main(){
int a,b;
cin>>a>>b;//读入每位同学可以分到的苹果数与同学数
cout<<a*b<<endl;//求出它们的积,就是答案
return 0;
}
P5704 【深基2.例6】字母转换
代码如下:
#include<iostream>
using namespace std;
int main()
{
char a,b;
cin >> a;
b = a - 32;
cout << b;
}
P5705 【深基2.例7】数字反转
代码如下:
#include <iostream>
#include <math.h>
using namespace std;
int main()
{
double a;
cin >> a;
int A = int(a * 10);
// 剥离各位置数字
int cnt = 0;
int save[10];
for (; A > 0; A /= 10)
{
save[cnt++] = A % 10;//储存顺序即是反转后的顺序
}
//翻转数字
double result = 0;
for (int i = 0; i <= cnt - 1; i++)
{
result += save[i] * pow(10, cnt - 1 - i);
}
a = result / 1000;
cout << a;
return 0;
}
P5706 【深基2.例8】再分肥宅水
代码如下:
#include<iostream>
#include<iomanip>
using namespace std;
int main(){
double t;
int n;
cin >> t >> n;
cout << setiosflags(ios::fixed); //只有在这项设置后,setprecision才是设置小数的位数
cout << setprecision(3) << t / n << endl << 2 * n;
return 0;
}
P5708 【深基2.习2】三角形面积
代码如下:
#include<iostream>
#include<math.h>
#include<iomanip>
using namespace std;
int main() {
double a, b, c;
cin >> a >> b >> c;
double p = (a + b + c) / 2;
double s = sqrt(p * (p - a) * (p - b) * (p - c));
cout << setprecision(1) << fixed << s;
return 0;
}
P5707 【深基2.例12】上学迟到
代码如下:
#include<iostream>
#include<iomanip>
#include<math.h>
using namespace std;
int main() {
int s, v, t, T = 8 * 60 - 10,h,m;
cin >> s >> v;
t = ceil(float(s) / v);
if (T >= t)
{
T -= t;
}
else
{
T = T + 24 * 60 - t;
}
h = T / 60;
m = T % 60;
cout << setfill('0') << setw(2) << h << ":" << setw(2) << setfill('0') << m;
return 0;
}
B2029 大象喝水
代码如下:
#include<iostream>
#include<math.h>
#include<iomanip>
using namespace std;
#define pai 3.14
#define need 20 * 1000
int main()
{
float h, r;
cin >> h >> r;
float buc = pai * h * pow(r, 2);
int n = ceil(need / buc);
cout << n;
return 0;
}
P1425 小鱼的游泳时间
代码如下:
#include<iostream>
using namespace std;
int main()
{
int a,b,c,d;
cin >> a >> b >> c >> d;
int e = (c * 60 + d - a * 60 - b) / 60;
int f = (c * 60 + d - a * 60 - b) % 60;
cout << e << " " << f;
return 0;
}
P1421 小玉买文具
代码如下:
#include<iostream>
using namespace std;
int main()
{
int a,b;
cin >> a >> b;
int n = (a*10 + b) / 19;
cout << n;
return 0;
}
P3954 [NOIP 2017 普及组] 成绩
代码如下:
#include<iostream>
using namespace std;
int main()
{
int A,B,C;
cin >> A >> B >> C;
int score = A*0.2 + B*0.3 + C*0.5;
cout << score;
return 0;
}