01:Hello, World!
#include<iostream>
#include<cstdio>
using namespace std;
int main(){
printf("Hello, World!");
return 0;
}
02:输出第二个整数
#include<iostream>
#include<cstdio>
using namespace std;
int main(){
int a,b,c;
cin>>a>>b>>c;
printf("%8d %8d %8d",a,b,c);
return 0;
}
03:对齐输出
#include<iostream>
#include<cstdio>
using namespace std;
int main(){
int a,b,c;
cin>>a>>b>>c;
printf("%8d %8d %8d",a,b,c);
return 0;
}
04:输出保留3位小数的浮点数
#include<cstdio>
int main(){
double x;
scanf("%lf",&x);
printf("%.3lf
",x);
return 0;
}
05:输出保留12位小数的浮点数
#include<cstdio>
int main(){
double x;
scanf("%lf",&x);
printf("%.12lf
",x);
return 0;
}
06:空格分隔输出
#include<cstdio>
int main(){
char a;
int b;
float c;
double d;
scanf("%c%d%f%lf",&a,&b,&c,&d);
printf("%c %d %f %lf", a, b, c, d);
return 0;
}
07:输出浮点数
#include<cstdio>
int main(){
double x;
scanf("%lf",&x);
printf("%lf
%.5lf
%e
%g
",x,x,x,x);
return 0;
}
08:字符三角形
#include<cstdio>
int main(){
int n = 3;
char ch;
ch = getchar();
for(int i = 1; i <= n; i++){
int e = i*2-1;
int blank = (5-e)/2;
for(int j = 1; j <= blank; j++){
printf(" ");
}
for(int j = 1; j <= e; j++){
printf("%c",ch);
}
printf("
");
}
return 0;
}
09:字符菱形
#include<cstdio>
int main(){
int n = 3;
char ch;
ch = getchar();
for(int i = 1; i <= n; i++){
int e = i*2-1;
int blank = (5-e)/2;
for(int j = 1; j <= blank; j++){
printf(" ");
}
for(int j = 1; j <= e; j++){
printf("%c",ch);
}
printf("
");
}
for(int i = n-1; i >= 1; i--){
int e = i*2-1;
int blank = (5-e)/2;
for(int j = 1; j <= blank; j++){
printf(" ");
}
for(int j = 1; j <= e; j++){
printf("%c",ch);
}
printf("
");
}
return 0;
}
10: 超级玛丽游戏
#include<cstdio>
int main(){
printf(" ********
");
printf(" ************
");
printf(" ####....#.
");
printf(" #..###.....##....
");
printf(" ###.......###### ### ### ### ###
");
printf(" ........... #...# #...# #...# #...#
");
printf(" ##*####### #.#.# #.#.# #.#.# #.#.#
");
printf(" ####*******###### #.#.# #.#.# #.#.# #.#.#
");
printf(" ...#***.****.*###.... #...# #...# #...# #...#
");
printf(" ....**********##..... ### ### ### ###
");
printf(" ....**** *****....
");
printf(" #### ####
");
printf(" ###### ######
");
printf("############################################################## ##################################
");
printf("#...#......#.##...#......#.##...#......#.##------------------# #...#......#.##------------------#
");
printf("###########################################------------------# ###############------------------#
");
printf("#..#....#....##..#....#....##..#....#....##################### #..#....#....#####################
");
printf("########################################## #----------# ############## #----------#
");
printf("#.....#......##.....#......##.....#......# #----------# #.....#......# #----------#
");
printf("########################################## #----------# ############## #----------#
");
printf("#.#..#....#..##.#..#....#..##.#..#....#..# #----------# #.#..#....#..# #----------#
");
printf("########################################## ############ ############## ############
");
}