笔记
SoleMotive.
这个作者很懒,什么都没留下…
展开
-
结构体内重载运算符
结构体内重载运算符struct student{ string name; int sum; //bool operator < (const student a) const{ // return this->sum>a.sum;(第一种重载形式) bool operator <(const student & a) const{ return sum>a.sum;(第二种重载形式) }};...原创 2021-07-16 09:38:55 · 722 阅读 · 0 评论 -
c++入门(结构体,vector,set)
新生入门:1:结构体结构体的创建:struct abc{ int a; char b; };结构体的命名:abc hh;结构体的引用:hh.a;2:vector#include<iostream>#include<vector>using namespace std;int main(){ int n,x; cin>>n; vector<int> a(n,5);//此表示有n个元素且全都初始为5// for(原创 2021-04-20 10:52:20 · 308 阅读 · 0 评论 -
【杭电oj】1251-统计题
题目其实这个题的思路是很有意思的,在读取单词表的时候用一个map将每个单词的所有的前缀都存起来,查询的时候直接访问键值就可以了。str.substr(pos,i)的意思就是从pos位置开始的长度为i的子串。getline(cin, s); //默认为回车符,若以其他符号为分隔符,改为getline(cin, s, ','),例如逗号代码:#include <bits\stdc++.h>#include <map>using namespace std;int m原创 2021-04-22 21:20:53 · 200 阅读 · 1 评论