2018年12月30日

C++ 构造器,这段代码错误原因,以及解决方案

摘要: 1 #include 2 #include 3 using namespace std; 4 class A 5 { 6 public: 7 /* 这段代码运行会崩溃,构造器初始化类的数据成员,只跟数据成员的声明的先后顺序有关 8 A(char * ps) 9 :name(ps),len(strlen(name.c_str())){} 10 11... 阅读全文

posted @ 2018-12-30 10:20 王朝马汉 阅读(256) 评论(0) 推荐(0) 编辑

2018年12月22日

string 数组的使用

摘要: 1 #include 2 #include 3 4 using namespace std; 5 /* 6 题目:读字符串 char buf[100] = “xxxx:yyyy:zzzz:aaaa:bbb”.按:进行分解到,string 数组中去。 7 */ 8 int main(void) 9 { 10 char buf[100] = "xxxx:yyyy:zz... 阅读全文

posted @ 2018-12-22 19:47 王朝马汉 阅读(508) 评论(0) 推荐(0) 编辑

2018年12月4日

双向链表的创建,查找,删除

摘要: 1 #include 2 #include 3 #include 4 /* 5 双向链表,创建,查找,删除 6 */ 7 //定义结构 8 typedef struct stu 9 { 10 char name[30]; 11 char sex; 12 int num; 13 float math; 14 float chinese... 阅读全文

posted @ 2018-12-04 09:27 王朝马汉 阅读(315) 评论(0) 推荐(0) 编辑

2018年12月1日

atoi 函数自实现

摘要: 1 #include 2 /* 3 编码实现字符串转整型的函数(实现函数 atoi 的功能)。如将字符串“123”转化为 123, 4 “-0123”转化为-123 5 */ 6 int myatoi(const char *p) 7 { 8 int val = 0; 9 int sign; 10 while(*p == ' '||*p == '\t'... 阅读全文

posted @ 2018-12-01 16:04 王朝马汉 阅读(267) 评论(0) 推荐(0) 编辑

2018年11月26日

strcmp,strcpy,strcat,strncmp,strncpy,strncat,自实现精炼版本

摘要: 1strcmp and strncmp 2.strcpy and strncpy 自实现精炼版本 3.strcat and strncat 自实现精炼版本 阅读全文

posted @ 2018-11-26 22:02 王朝马汉 阅读(181) 评论(0) 推荐(0) 编辑

2018年11月19日

天生棋局(堆上申请二维空间的应用)

摘要: 1 #include 2 #include 3 /* 4 天生棋局 5 */ 6 #define N 10 7 //1.传入一个n在堆空间中产生n*n方格的棋盘(生成一个n*n的二维空间) 8 int **createboard(int n) 9 { 10 int **p = (int **)malloc(n*sizeof(int*)); 11 fo... 阅读全文

posted @ 2018-11-19 13:32 王朝马汉 阅读(301) 评论(0) 推荐(0) 编辑

2018年11月13日

使用二级指针,初始化一级指针

摘要: 1 #include 2 #include 3 #include 4 enum 5 { 6 Success,NameErr,SexErr,StrNumErr,ScoreErr 7 }; 8 typedef struct stu 9 { 10 char *name; 11 char *sex; 12 char *strNum; 13 ... 阅读全文

posted @ 2018-11-13 19:06 王朝马汉 阅读(930) 评论(0) 推荐(0) 编辑

2018年11月9日

指针数组的简单理解

摘要: 1 #include 2 /* 3 研究类型,步长,数组名和二级指针的关系 4 */ 5 int main(void) 6 { 7 char *p[4] = {"1234","sq34","d234","4234"}; 8 //万变不离其中:数组名 == 首元素的地址 9 //1.整体研究 10 printf("sizeof(p) = %d\n... 阅读全文

posted @ 2018-11-09 19:44 王朝马汉 阅读(404) 评论(0) 推荐(0) 编辑

2018年11月2日

输入二进制数,输出10进制数

摘要: 1 #include 2 #include 3 #include 4 using namespace std; 5 /* 6 打印二进制的十进制数,输入010101111 二进制数 输出10进制数 7 */ 8 int main(void) 9 { 10 int val; int val1 = 0 ,i = 0; 11 printf("输入二进制数\n"... 阅读全文

posted @ 2018-11-02 10:49 王朝马汉 阅读(738) 评论(0) 推荐(0) 编辑

阶乘循环联系题

摘要: 1 #include 2 #include 3 using namespace std; 4 int init() 5 { 6 int i; 7 printf("请输入一个非负整数\n"); 8 scanf("%d",&i); 9 return i; 10 } 11 void input(int i ,int j) 12 { 13 p... 阅读全文

posted @ 2018-11-02 10:36 王朝马汉 阅读(177) 评论(0) 推荐(0) 编辑

导航