![](https://img-blog.csdnimg.cn/20201014180756928.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
cpp
文章平均质量分 57
Wei *
这个作者很懒,什么都没留下…
展开
-
【c++语法】字符串
文章目录读入输出函数string做题时遇到的知识点读入char s[100];// 到空格、换行等就会结束scanf("%s", s);cin >> s;// 不受空格限制char s[100];fgets(s, 100, stdin);cin.getline(s, 100);// 或者string s;getline(cin, s);输出printf("%s\n",s);cout << s;// 只能用于char[] sputs(s);函数原创 2022-01-17 13:56:37 · 224 阅读 · 0 评论 -
【c++语法】类、结构体、指针、引用
文章目录类结构体和类的区别构造函数指针引用链表类关键字:public、private作用范围直到下一个关键字结构体和类的区别没有关键字的成员结构体默认public类默认privatestruct stu { int grade; float score;};struct stu arr1[10]; // C语⾔⾥⾯需要写成struct stustu arr2[10];// C++⾥⾯不⽤写struct,直接写stu就好了~构造函数名字与类名相同,可以有参数。一种原创 2022-01-17 13:55:15 · 272 阅读 · 0 评论 -
【c++语法】位运算与常用库函数
位运算& 与| 或~ 非^ 异或>> 右移<< 左移常用操作:(1) 求x的第k位数字 x >> k & 1(2) lowbit(x) = x & -x,返回x的最后一位1 (其中-x = ~x + 1)int a = 2;cout << (a & -a) << endl; // 2int a = 12;cout << (a & -a) << end原创 2022-01-17 13:53:45 · 353 阅读 · 0 评论 -
【c++语法】STL个人总结
文章目录vectorqueuestackdequesetmapbitsetpairvector相当于动态数组/不定长数组#include <vector> // 头文件vector<int> a; // 相当于一个长度动态变化的int数组vector<int> a({1, 2, 3}); vector<int> a(7); // 初始化为长度为7,值为默认vector<int> a(7, 3);// 初始化为长度为7,值均为3原创 2022-01-02 19:43:34 · 404 阅读 · 0 评论