随笔分类 -  C++&C

摘要:问题 #include <iostream> using namespace std; int main() { char * p=&"good"; cout<<p; } 报错: error: cannot convert ‘const char (*)[5]’ to ‘char*’ in init 阅读全文
posted @ 2022-05-24 21:01 ShineLe 阅读(1222) 评论(0) 推荐(0) 编辑
摘要:set结构具有自动排序特性,排序依据是Key,set中的value与key合一,key就是value 构造set集合是为了快速检索,使用set前,需要在程序头文件中包含声明#include<set> 特点: 1、set不允许元素重复 2、不能直接改变元素值,因为那样会打乱原本正确的顺序,改变元素值之 阅读全文
posted @ 2020-05-12 12:44 ShineLe 阅读(736) 评论(0) 推荐(0) 编辑
摘要:Q:一个数字是以xxx,yyy,zzz的字符串形式存储的,将逗号消去并转化为整数输出 方法一:char数组,即定义时s1定义为 char s1[20]的形式; //删除输入字符串中的逗号,并构建新串 for(i=j=0;*(s1+i)!='\0';i++) if(s1[i]!=',') s1[j++ 阅读全文
posted @ 2020-03-25 20:45 ShineLe 阅读(19608) 评论(0) 推荐(1) 编辑
摘要:class P{ public: int id; char name[10]; int age; P() { this->id = 0; for (int i = 0; i < 10; i++) this->name[i] = '\0'; this->age = 0; } void operator 阅读全文
posted @ 2020-03-25 16:51 ShineLe 阅读(315) 评论(0) 推荐(0) 编辑
摘要:Vector:一个容器,可以构建链表等数据结构 #include<vector> using namespace std; 创建一个vector对象 vector <int> I1; //一个int型的空的vector对象I1 vector <int> I2(500); //包含500个int类型数 阅读全文
posted @ 2020-03-24 23:12 ShineLe 阅读(318) 评论(0) 推荐(0) 编辑
摘要:头文件#include<string>不能写成#include<string.h> 阅读全文
posted @ 2020-03-20 16:32 ShineLe 阅读(584) 评论(0) 推荐(0) 编辑
摘要:string库 1、size()与length() 字符串长,结果相同 string s; s.length(); //s.length()-1是最后一个字符的下标,而不是'\0' for(i=0;i<s.length()-1;i++) cout<<s[i]<<endl; //可以输出每个字符 s. 阅读全文
posted @ 2020-03-16 23:41 ShineLe 阅读(490) 评论(0) 推荐(0) 编辑
摘要:https://jingyan.baidu.com/article/49711c616b8a1ffa441b7cdc.html 阅读全文
posted @ 2020-01-07 21:04 ShineLe 阅读(369) 评论(0) 推荐(0) 编辑
摘要:程序末尾添加 system("pause"); 阅读全文
posted @ 2020-01-07 15:33 ShineLe 阅读(241) 评论(0) 推荐(0) 编辑
摘要:按 “F5”(开始调试的快捷键)运行到下个断点处。 阅读全文
posted @ 2020-01-07 15:22 ShineLe 阅读(297) 评论(0) 推荐(0) 编辑
摘要:1、使用前应先包含头文件string.h,有的是cstring #include<string> 这样才能正确的cin和cout字符串。 cin时,是按照空格、TAB和换行进行分割的 例如,输入Hello World 使用cin输入,监视输入的对象,可以看到,是分Hello 和World两次cin的 阅读全文
posted @ 2020-01-07 15:18 ShineLe 阅读(410) 评论(0) 推荐(0) 编辑
摘要:菜单栏 “工具”->选项->环境->常规 阅读全文
posted @ 2020-01-05 21:44 ShineLe 阅读(361) 评论(0) 推荐(0) 编辑
摘要:https://blog.csdn.net/glw0223/article/details/93195009 阅读全文
posted @ 2020-01-05 21:38 ShineLe 阅读(1077) 评论(0) 推荐(0) 编辑
摘要://创建 int **a=new int *[n]; for(i=0;i<n;i++) a[i]=new int[n]; // …… // 删除 for(i=0;i<n;i++) delete [] a[i]; delete [] a; 阅读全文
posted @ 2020-01-05 20:52 ShineLe 阅读(477) 评论(0) 推荐(0) 编辑
摘要:在第一行#include<iostream>下边一行加上一句 using namespace std; 阅读全文
posted @ 2020-01-04 13:59 ShineLe 阅读(836) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示