c
岑**
这个作者很懒,什么都没留下…
展开
-
字符串与数字之间的转换
字符串与数字之间的转换 atof() 的功能:(将字串转换成浮点型数) 相关函数: atoi,atol,strtod,strtol,strtoul 所属库名:<math.h> and <stdlid.h> 头文件: #include <stdlib.h> 定义函数:double atof(const char *nptr); 函数说明: atof()会扫描...原创 2020-10-25 11:38:50 · 177 阅读 · 0 评论 -
杨辉三角——二维数组
杨辉三角 形如: 1 1 1 1 2 1 1 3 3 1 1 4 6 4 1 特点:0列和对角线及第二行全为1,其他元素均为上一行同列元素与前一列元素之和。 main() { int n,i,j; scanf("%d",&n);//行数 if (n>0) { int a[n][n]; for(i=0;i<n;i++) { for(j=0;j<=i;j++) { if (j==0||i==j||(i==1&&j==1)) {原创 2020-07-26 16:15:25 · 603 阅读 · 0 评论 -
将一个字符串前 K 个字符逆转到字符串尾部
#将一个字符串前 K 个字符逆转到字符串尾部 例:输入 str :abcXYZdefg k=3 out : XYZdefgabc 分析:利用strcpy() 与strncat() 函数完成逆转。 代码实现 #include <stdio.h> #include <string.h> int main() { ...原创 2019-11-24 18:53:11 · 456 阅读 · 0 评论