目录
P5731 【深基5.习6】蛇形方阵 - 输出格式
P5732 【深基5.习7】杨辉三角 - 经典数学
P1957 口算练习题
小知识1:函数的用法
P1308 [ 普及组] 统计单词数
小知识2:C++输入带空格字符串;
P5731 【深基5.习6】蛇形方阵 - 输出格式
123412 13 14511 16 15610987
可以说是水题了,但是全WA,debug了半天,原来是输出格式有毒
AC:
#include
如果是n*m的蛇形方阵呢?
#include
P5732 【深基5.习7】杨辉三角 - 经典数学
11 11 2 11 3 3 11 4 6 4 11 5 10 10 5 1
思路:先定义一个二维数组:a[N][N],略大于要打印的行数 。再令两边的数为 1,即当每行的第一个数和最后一个数为 1 。a[i][0]=a[i][i-1]=1,n 为行数 。除两边的数外,任何一个数为上两顶数之和,即 a[i][j] = a[i-1][j-1] + a[i-1][j] 。
#include
P1957 口算练习题
4a 64 46275 125c 11 99b 46 64
小知识:
函数的用法
函数的格式:
int ( char *, const char * [, ,…] );
1、可以控制精度,还能“四舍五入”
#include
2、可以将多个数值数据连接起来
char str[20];int a=20984,b=48090;sprintf(str,”%3d%6d”,a,b);str[]=”20984 48090”
3、 可以将多个字符串连接成字符串
char str[20];char s1[5]={'A','B','C'};char s2[5]={'x','y','z'};sprintf(str,"%.3s%.3s",s1,s2);str="ABCxyz";
%m.n在字符串的输出中,m表示宽度,字符串共占的列数;n表示实际的字符数 。%m.n在浮点数中,m也表示宽度;n表示小数的位数 。
4、
之后的操作基本跟一样,只不过是函数打印到字符串中(要注意字符串的长度要足够容纳打印的内容,否则会出现内存溢出),而函数打印输出到屏幕上 。
明白用法后,这题直接秒杀:
#include
- 【笔试刷题训练】day_04
- 和孝公主性情刚毅不爱红装爱武装
- 带图详解 【算法模板】高精度模板
- 336个幽默成语之“最”大合集, 有趣又好记!给孩子收藏细读 世界之最成语
- 清朝太监用什么方法防死后被掘坟?
- P5730 【深基5.例10】显示屏 - 字符表问题
- 徐昭佩是谁?萧绎只得徐妃半面妆的故事
- 秦始皇陵迷之地宫:受高人指点构建江河湖海
- 上 html5+css3学习
- 配柴油2.0升动力,欧马可S1新小卡能拉1.8吨货,售价9.66万起 柴油轻卡汽车大全