遇到的小知识点
_ymi
/(ㄒoㄒ)/~~
展开
-
字符串操作
1 对于字符串数组的操作可以输入空格—gets() 、cin.get() 、cin.getline() 、strlen 计算字符串数组的长度,计算长度的时候不会把\0计算进去strcat 拼接函数strcpy 拷贝函数strcmp 比较函数void text01(){// gets(b);//可以输入空格// cin.get(b,4); //接收3个字符+'\0 ',,当然也可以接收空格呀 cin.getline(b,4);//这俩差不多哈哈 cout<<a原创 2021-03-13 14:26:23 · 537 阅读 · 0 评论 -
sort
C语言qsort#include<iostream>#include<cstdio>#include<cstdlib>using namespace std;void print(int *array,int n){ for(int i=0;i<n;i++){ cout<<array[i]<<" "; } cout<<endl;}int cmp(const void* a,const void* b){原创 2020-12-29 20:45:47 · 75 阅读 · 0 评论 -
pair
112.雷达设备两个注意的地方:按照 尾 排序以选中的第一个区间的 尾 去和下一个区间的 首 比较#include<bits/stdc++.h>using namespace std;typedef pair<double,double>PDD;const int N=1010;const double eps=1e-6, INF=1e10;int n,d;PDD seg[N];int main(){ cin>>n>>d; b原创 2020-10-15 12:06:08 · 73 阅读 · 0 评论 -
链表传递
一般情况下,向函数传递指针类型的参数,可以让函数改变指针指向的内容,并将改变的效果返回但是,如果要改变指针本身的值,使它指向新开辟的内存空间,而不是改变它指向内容的值,这里有两个方法,①是引用,无返回值 ②是传递指向指针的指针,即二级指针void Attach1(int coef,int expon,pnode &p){ pnode ptr; ptr=new node(); ptr->coef =coef; ptr->expon =expon; ptr->nex.原创 2020-10-13 20:49:14 · 486 阅读 · 0 评论 -
sort
1.对string排序#include<bits/stdc++.h>using namespace std;vector<string>a;bool compare1(string a,string b){ return a>b;}//升序bool compare2(string a,string b){ return a.size()>b.size();}//字符串的长度 int main(){ int n;cin>>n; .原创 2020-10-10 21:10:28 · 123 阅读 · 0 评论 -
auto
今天遇到auto,所以来总结一下在之前devc++需要支持一下c++111auto代替for循环#include<bits/stdc++.h>using namespace std;vector<string>a;bool compare1(string a,string b){ return a>b;}//升序bool compare2(string a,string b){ return a.size()>b.size();}//字符串的长原创 2020-10-10 20:52:56 · 87 阅读 · 0 评论