https://www.luogu.com.cn/training/100#problems
B2002 Hello,World!
#include<bits/stdc++.h>
using namespace std;
int main(void)
{
printf("Hello,World!");
return 0;
}
B2025 输出字符菱形
#include<bits/stdc++.h>
using namespace std;
int main(void)
{
for(int i=1;i<=3;i++)
{
for(int j=1;j<=3-i;j++)
cout<<" ";
for(int j=1;j<=i*2-1;j++)
cout<<"*";
puts("");
}
for(int i=2;i>=1;i--)
{
for(int j=1;j<=2-i+1;j++) cout<<" ";
for(int j=1;j<=i*2-1;j++)
cout<<"*";
puts("");
}
return 0;
}
P1000 超级玛丽游戏
#include<stdio.h>
int main() {
printf(
" ********\n"
" ************\n"
" ####....#.\n"
" #..###.....##....\n"
" ###.......###### ### ###\n"
" ........... #...# #...#\n"
" ##*####### #.#.# #.#.#\n"
" ####*******###### #.#.# #.#.#\n"
" ...#***.****.*###.... #...# #...#\n"
" ....**********##..... ### ###\n"
" ....**** *****....\n"
" #### ####\n"
" ###### ######\n"
"##############################################################\n"
"#...#......#.##...#......#.##...#......#.##------------------#\n"
"###########################################------------------#\n"
"#..#....#....##..#....#....##..#....#....#####################\n"
"########################################## #----------#\n"
"#.....#......##.....#......##.....#......# #----------#\n"
"########################################## #----------#\n"
"#.#..#....#..##.#..#....#..##.#..#....#..# #----------#\n"
"########################################## ############\n"
);
return 0;
}
P1001 A+B Problem
#include<stdio.h>
int main(void)
{
int a,b;
scanf("%d %d",&a,&b);
printf("%d",a+b);
return 0;
}
B2005 字符三角形
#include<bits/stdc++.h>
using namespace std;
int main(void)
{
string c; cin>>c;
for(int i=1;i<=3;i++)
{
for(int j=1;j<=3-i;j++) cout<<" ";
for(int j=1;j<=i*2-1;j++) cout<<c;
puts("");
}
return 0;
}
P5703 【深基2.例5】苹果采购
#include<stdio.h>
int main(void)
{
unsigned long a,b;
scanf("%lu %lu",&a,&b);
printf("%lu",a*b);
return 0;
}
P5704 【深基2.例6】字母转换
#include<stdio.h>
int main(void)
{
char a;
a=getchar();
printf("%c\n",a-32);
return 0;
}
P5705 【深基2.例7】数字反转
#include<bits/stdc++.h>
using namespace std;
int main(void)
{
string s; cin>>s;
reverse(s.begin(),s.end());
cout<<s;
return 0;
}
P5706 【深基2.例8】再分肥宅水
#include<stdio.h>
int main(void)
{
double V;
int n;
scanf("%lf %d",&V,&n);
printf("%.3lf\n%d",V/n,n*2);
return 0;
}
P5708 【深基2.习2】三角形面积
#include<stdio.h>
#include<math.h>
int main(void)
{
double a,b,c;
double sum;
scanf("%lf %lf %lf",&a,&b,&c);
sum=(a+b+c)/2.0;
sum=sum*(sum-a)*(sum-b)*(sum-c);
printf("%.1lf",sqrt(sum));
return 0;
}
P5707 【深基2.例12】上学迟到
#include<cstdio>
#include<iostream>
#include<cmath>
using namespace std;
int a1=8*60;
int a2=24*60;
int main(void)
{
int s,v; cin>>s>>v;
int t;
if(s%v==0) t=s/v;
else t=s/v+1;
int temp=a1-t-10;
if(temp>=0)
{
printf("%02d:%02d\n",temp/60,temp%60);
}
else
{
temp=a2+temp;
printf("%02d:%02d\n",temp/60,temp%60);
}
return 0;
}
B2029 大象喝水
#include<bits/stdc++.h>
using namespace std;
#define pi 3.1415926
int main(void)
{
double h,r; cin>>h>>r;
int ans=ceil(20*1000/(h*pi*r*r));
cout<<ans<<endl;
return 0;
}
P1425 小鱼的游泳时间
#include<cstdio>
#include<iostream>
using namespace std;
int main(void)
{
int a,b,c,d; cin>>a>>b>>c>>d;
int sum1=a*60+b;
int sum2=c*60+d;
printf("%d %d\n",(sum2-sum1)/60,(sum2-sum1)%60);
return 0;
}
P1421 小玉买文具
#include<cstdio>
#include<iostream>
using namespace std;
int main(void)
{
int a=19;
int s1,s2; cin>>s1>>s2;
cout<<(s1*10+s2)/a<<endl;
return 0;
}
P3954 [NOIP2017 普及组] 成绩
#include<stdio.h>
int main(void)
{
int A, B,C;
int sum=0;
scanf("%d %d %d",&A,&B,&C);
sum=A*0.2+B*0.3+C*0.5;
printf("%d",sum);
return 0;
}