03 2020 档案

摘要: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) 编辑

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