01:Hello, World!
#include
int main(void)
{
printf("Hello, World!");
return 0;
}
02:输出第二个整数
#include
int main(void)
{
int a, b, c;
scanf("%d%d%d", &a, &b, &c);
printf("%d", b);
return 0;
}
03:对齐输出
#include
int main(void)
{
int a, b, c;
scanf("%d%d%d", &a, &b, &c);
printf("%8d %8d %8d", a, b, c);/* 注意输出的格式 */
return 0;
}
04:输出保留3位小数的浮点数
#include
int main(void)
{
float num;
scanf("%f", &num);
printf("%.3f", num);/* 注意输出的格式 */
return 0;
}
05:输出保留12位小数的浮点数
#include
int main(void)
{
double num;
scanf("%lf", &num);
printf("%.12f", num);/* 注意输出的格式 */
return 0;
}
06:空格分隔输出
#include
int main(void)
{
char ch;
int a;
float b;
double c;
scanf("%c%d%f%lf", &ch, &a, &b, &c);
printf("%c %d %.6f %.6lf", ch, a, b, c);
return 0;
}
07:输出浮点数
#include
int main(void)
{
double num;
scanf("%lf", &num);
printf("%f\n%.5f\n%e\n%g", num, num, num, num);/* \n是回车换行符,将当前位置移到下一行开头 */
return 0;
}
08:字符三角形
#include
int main(void)
{
char ch;
scanf("%c", &ch);
/* 输出空格来代替空白 */
printf(" %c \n", ch);
printf(" %c%c%c \n", ch, ch, ch);
printf("%c%c%c%c%c\n", ch, ch, ch, ch, ch);
return 0;
}
09:字符菱形
#include
int main(void)
{
char ch;
scanf("%c", &ch);
/* 输出空格来代替空白 */
printf(" %c \n", ch);
printf(" %c%c%c \n", ch, ch, ch);
printf("%c%c%c%c%c\n", ch, ch, ch, ch, ch);
printf(" %c%c%c \n", ch, ch, ch);
printf(" %c \n", ch);
return 0;
}
10:超级玛丽游戏
这道题。。。直接输出就可以了。。。。
#include
int main(void)
{
printf(" ********\n");
printf(" ************\n");
printf(" ####....#.\n");
printf(" #..###.....##....\n");
printf(" ###.......###### ### ### ### ###\n");
printf(" ........... #...# #...# #...# #...#\n");
printf(" ##*####### #.#.# #.#.# #.#.# #.#.#\n");
printf(" ####*******###### #.#.# #.#.# #.#.# #.#.#\n");
printf(" ...#***.****.*###.... #...# #...# #...# #...#\n");
printf(" ....**********##..... ### ### ### ###\n");
printf(" ....**** *****....\n");
printf(" #### ####\n");
printf(" ###### ######\n");
printf("############################################################## ##################################\n");
printf("#...#......#.##...#......#.##...#......#.##------------------# #...#......#.##------------------#\n");
printf("###########################################------------------# ###############------------------#\n");
printf("#..#....#....##..#....#....##..#....#....##################### #..#....#....#####################\n");
printf("########################################## #----------# ############## #----------#\n");
printf("#.....#......##.....#......##.....#......# #----------# #.....#......# #----------#\n");
printf("########################################## #----------# ############## #----------#\n");
printf("#.#..#....#..##.#..#....#..##.#..#....#..# #----------# #.#..#....#..# #----------#\n");
printf("########################################## ############ ############## ############\n");
return 0;
}
写在最后
该博客仅供参考