摘要: 1:头文件 #include <string> 声明一个string变量,形式如下: std::string s; 初始化string类型的变量: std::string s1("字符串"); std::string s2="字符串"; std::string s3=(3,'A');//s3的内容为 阅读全文
posted @ 2017-09-17 21:43 一串字符串 阅读(533) 评论(0) 推荐(0) 编辑
摘要: 1:有时在获得一定的信息之前,我们并不确定数组的大小。动态分配数组则可以使用变量作为数组的大小,使数组的大小符合我们的要求。 2:科普一下斐波纳契数列:斐波那契数列指的是这样一个数列 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233,377,610,987 阅读全文
posted @ 2017-09-17 14:51 一串字符串 阅读(528) 评论(0) 推荐(0) 编辑
摘要: 1:代码如下: // 6.17.cpp : 定义控制台应用程序的入口点。 // #include "stdafx.h" #include<iostream> using namespace std; void mix(int (*a)[4],int m)//形参是定义一个指向数组的指针 //进行比较 阅读全文
posted @ 2017-09-17 11:08 一串字符串 阅读(1063) 评论(0) 推荐(0) 编辑
摘要: 1:代码如下 // 6.15.cpp : 定义控制台应用程序的入口点。 // #include "stdafx.h" #include <iostream> using namespace std; void main() { char str1[50], str2[30], *p1, *p2; p 阅读全文
posted @ 2017-09-17 10:04 一串字符串 阅读(3441) 评论(0) 推荐(0) 编辑
摘要: 1:字符数组是一个一维数组,引用字符数组的指针为字符指针,字符指针就是指向字符型内存空间的指针变量。 char *p; char *string="www.mingri.book"; 2:实例,通过指针连接两个字符数组,代码如下: // 6.14.cpp : 定义控制台应用程序的入口点。 // #i 阅读全文
posted @ 2017-09-17 09:24 一串字符串 阅读(3232) 评论(0) 推荐(0) 编辑
摘要: 1:代码如下: // 6.13.cpp : 定义控制台应用程序的入口点。 // #include"stdafx.h" #include<iostream> using namespace std; void main() { int a[3][4]; int (*b)[4];//指向int数组的指针 阅读全文
posted @ 2017-09-17 09:06 一串字符串 阅读(268) 评论(0) 推荐(0) 编辑
摘要: 1:以a[4][3]为例 a代表二维数组的地址,通过指针运算符可以获取数组中的元素 (1)a+n代表第n行的首地址 (2)&a[0][0]既可以看作第0行0列的首地址,同样也可以被看作是二维数组的首地址。&a[m][n]就是第m行n列元素的地址 (3)&a[0]是第0行的首地址,当然&a[n]就是第 阅读全文
posted @ 2017-09-17 08:48 一串字符串 阅读(1828) 评论(0) 推荐(0) 编辑
摘要: 1:代码如下: // 6.11.cpp : 定义控制台应用程序的入口点。 // #include "stdafx.h" #include <iostream> #include <iomanip> using namespace std; void main() { int a[4][3]={1,2 阅读全文
posted @ 2017-09-17 08:17 一串字符串 阅读(1114) 评论(0) 推荐(0) 编辑
摘要: 1:代码如下: // 6.10.cpp : 定义控制台应用程序的入口点。 // #include "stdafx.h" #include <iostream> using namespace std; void main() { int array1[3][4]={{1,2,3,4}, {5,6,7 阅读全文
posted @ 2017-09-17 08:06 一串字符串 阅读(914) 评论(0) 推荐(0) 编辑