这些代码都是通过测试的
1.Hello, World!
#include<bits/stdc++.h>
using namespace std;
int main(){
cout<<"Hello, World!";
return 0;
}
02.输出第二个整数
#include<bits/stdc++.h>
using namespace std;
int main(){
int a,b,c;
cin>>a>>b>>c;
cout<<b;
return 0;
}
03.对齐输入
#include<bits/stdc++.h>
using namespace std;
int main(){
int a,b,c;
cin>>a>>b>>c;
printf("%8d %8d %8d\n",a,b,c);
return 0;
}
04.输出保留3位小数的浮点数
#include<bits/stdc++.h>
using namespace std;
int main(){
float a;
cin>>a;
cout<<fixed<<setprecision(3)<<a;
return 0;
}
05.输出保留12位小数的浮点数
#include<bits/stdc++.h>
using namespace std;
int main(){
double a;
cin>>a;
cout<<fixed<<setprecision(12)<<a;
return 0;
}
06.空格分隔输出
#include<bits/stdc++.h>
using namespace std;
int main(){
char a;
long long b;
float c;
double d;
cin>>a>>b>>c>>d;
cout<<a<<' '<<b<<' '<<fixed<<setprecision(6)<<c<<' '<<fixed<<setprecision(6)<<d;
return 0;
}
07.输出浮点数
#include<bits/stdc++.h>
using namespace std;
int main(){
double d;
cin>>d;
printf("%f\n%.5lf\n%e\n%g\n",d,d,d,d);
return 0;
}
08.字符三角形
#include<bits/stdc++.h>
using namespace std;
int main(){
char a;
cin>>a;
cout<<" "<<a<<endl<<' '<<a<<a<<a<<endl<<a<<a<<a<<a<<a;
return 0;
}
09.字符菱形
#include<bits/stdc++.h>
using namespace std;
int main(){
char a;
cin>>a;
cout<<" "<<a<<endl<<' '<<a<<a<<a<<endl<<a<<a<<a<<a<<a<<endl<<' '<<a<<a<<a<<endl<<" "<<a;
return 0;
}
10.超级玛丽游戏
#include<bits/stdc++.h>
using namespace std;
int main()
{
cout<<" ********"<<endl<<" ************"<<endl<<" ####....#."<<endl<<" #..###.....##...."<<endl<<" ###.......###### ### ### ### ###"<<endl<<" ........... #...# #...# #...# #...#"<<endl<<" ##*####### #.#.# #.#.# #.#.# #.#.#"<<endl<<" ####*******###### #.#.# #.#.# #.#.# #.#.#"<<endl<<" ...#***.****.*###.... #...# #...# #...# #...#"<<endl<<" ....**********##..... ### ### ### ###"<<endl<<" ....**** *****...."<<endl<<" #### ####"<<endl<<" ###### ######"<<endl<<"############################################################## ##################################"<<endl<<"#...#......#.##...#......#.##...#......#.##------------------# #...#......#.##------------------#"<<endl<<"###########################################------------------# ###############------------------#"<<endl<<"#..#....#....##..#....#....##..#....#....##################### #..#....#....#####################"<<endl<<"########################################## #----------# ############## #----------#"<<endl<<"#.....#......##.....#......##.....#......# #----------# #.....#......# #----------#"<<endl<<"########################################## #----------# ############## #----------#"<<endl<<"#.#..#....#..##.#..#....#..##.#..#....#..# #----------# #.#..#....#..# #----------#"<<endl<<"########################################## ############ ############## ############"<<endl;
return 0;
}