目录
B2002 Hello,World!
源代码:
#include<iostream>
using namespace std;
int main(){
cout<<"Hello,World!"<<endl;
return 0;
}
B2025 输出字符菱形
源代码:
#include<iostream>
using namespace std;
int main(){
for(int i=1;i<=3;i++){
for(int j=i;j<3;j++) cout<<" ";
for(int j=1;j<=i*2-1;j++){
cout<<"*";
}
cout<<endl;
}
for(int i=2;i>=1;i--){
for(int j=i;j<3;j++) cout<<" ";
for(int j=1;j<=i*2-1;j++){
cout<<"*";
}
cout<<endl;
}
return 0;
}
P1000 超级玛丽游戏
源代码:
#include <iostream>
using namespace std;
int main(){
cout<<" ********"<<endl;
cout<<" ************"<<endl;
cout<<" ####....#."<<endl;
cout<<" #..###.....##...."<<endl;
cout<<" ###.......###### ### ###"<<endl;
cout<<" ........... #...# #...#"<<endl;
cout<<" ##*####### #.#.# #.#.#"<<endl;
cout<<" ####*******###### #.#.# #.#.#"<<endl;
cout<<" ...#***.****.*###.... #...# #...#"<<endl;
cout<<" ....**********##..... ### ###"<<endl;
cout<<" ....**** *****...."<<endl;
cout<<" #### ####"<<endl;
cout<<" ###### ######"<<endl;
cout<<"##############################################################"<<endl;
cout<<"#...#......#.##...#......#.##...#......#.##------------------#"<<endl;
cout<<"###########################################------------------#"<<endl;
cout<<"#..#....#....##..#....#....##..#....#....##################### "<<endl;
cout<<"########################################## #----------#"<<endl;
cout<<"#.....#......##.....#......##.....#......# #----------#"<<endl;
cout<<"########################################## #----------#"<<endl;
cout<<"#.#..#....#..##.#..#....#..##.#..#....#..# #----------#"<<endl;
cout<<"########################################## ############"<<endl;
return 0;
}
P1001 A+B Problem
源代码:
#include <iostream>
using namespace std;
int main(){
int a,b;
cin>>a>>b;
cout<<a+b<<endl;
return 0;
}
B2005 字符三角形
源代码:
#include<iostream>
#include<cstring>
#include<string>
#include<cstdio>
#include<cstdlib>
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;
}
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;
cin>>a;
cout<<char(a-32);
return 0;
}
P5705 【深基2.例7】数字反转
源代码:
#include<iostream>
#include<cstring>
#include<string>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<cmath>
using namespace std;
int main(){
string a;
cin>>a;
for(int i=a.size()-1;i>=0;i--){
cout<<a[i];
}
return 0;
}
P5706 【深基2.例8】再分肥宅水
源代码:
#include<iostream>
#include<cstring>
#include<string>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<cmath>
using namespace std;
int main(){
double a;
int b;
cin>>a>>b;
printf("%0.3lf\n",a/b);
cout<<b*2;
return 0;
}
P5708 【深基2.习2】三角形面积
源代码:
#include<iostream>
#include<cstring>
#include<string>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<cmath>
using namespace std;
int main(){
double a,b,c;
cin>>a>>b>>c;
double p=0.5*(a+b+c);
double s=sqrt(p*(p-a)*(p-b)*(p-c));
printf("%0.1lf",s);
return 0;
}
P5707 【深基2.例12】上学迟到
源代码:
#include<iostream>
#include<cstring>
#include<string>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<iomanip>
using namespace std;
int main()
{
int a,b,c;
cin>>a>>b;
if(a%b==0) c=a/b;
else if(a%b!=0) c=a/b+1;
int d=c+10;//d为花的时间
int e=d%60;
int f=(d-e)/60;
if(d<=480){
int g=7-f,h=60-e;
if(h==60){
h=0;
g++;
}
cout<<0<<g<<":";
if(h<10){
cout<<0;
}
cout<<h;
}else{
int g=(f-8)%24;
int z=23-g,h=60-e;
if(h==60){
h=0;
z++;
}
if(z<10){
cout<<0;
}
cout<<z<<":";
if(h<10){
cout<<0;
}
cout<<h;
}
return 0;
}
B2029 大象喝水
源代码:
#include<iostream>
using namespace std;
int main(){
double pi=3.14;
int h,r;
cin>>h>>r;
double v=pi*r*r*h;
double sum=20000.00/v;
if(int(sum)==sum||int(sum)+1==sum){
cout<<sum<<endl;
}else{
cout<<int(sum)+1<<endl;
}
return 0;
}
P1425 小鱼的游泳时间
源代码:
#include<iostream>
#include<cstring>
#include<string>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<cmath>
using namespace std;
int main(){
int a,b,c,d,e,f;
cin>>a>>b>>c>>d;
int g=(c*60+d)-(a*60+b);
int h=g%60;
int i=(g-h)/60;
cout<<i<<" "<<h;
return 0;
}
P1421 小玉买文具
源代码:
#include<iostream>
#include<cstring>
#include<string>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<cmath>
using namespace std;
int main(){
int a,b;
cin>>a>>b;
int c=a*10+b;
cout<<c/19<<endl;
return 0;
}
P3954 [NOIP2017 普及组] 成绩
源代码:
#include<iostream>
#include<cstring>
#include<string>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<cmath>
using namespace std;
int main(){
int a,b,c;
cin>>a>>b>>c;
cout<<a/5+b/10*3+c/2;
return 0;
}