acm

1.数组容器:vector

#include<vector>
vector<string> s;
s.push_back(str);
sort(s.begin(),s.end());
for(auto x:s)
  {
       cout<<x<<endl;
  }

2.排序:sort

#include<algorithm>
sort(s.begin(),s.end());

3.除重排序:set

#include <set>
set<int> s;
s.insert(1);
cout<<"set 的 size 值为 :"<<s.size()<<endl;
cout<<"set 的 maxsize的值为 :"<<s.max_size()<<endl;
cout<<"set 中的第一个元素是 :"<<*s.begin()<<endl;
cout<<"set 中的最后一个元素是:"<<*s.end()<<endl;
set<int>::iterator it;  
for(it = s.begin(); it != s.end(); it++)
{
   cout << *it << " ";  
cout << endl;  
}

4.翻转reverse

#include<bits/stdc++.h>
reverse(str.begin(),str.end());

5.string、char、int

#include <string>
#include <cstring>
//char*和string互转
string s1 = "demo";
char *p = "demo";
s1 = p;
const char * p = s.c_str();
//int转string
int i=0;
string str=to_string(i);
//char转int
char a='9';
int i=(int)(a-'0');

6.字符串比较

bool test(string r,const char * i){
   if(strstr(r.c_str(),i))
      return true;
   else
       return false;  
}

7.

a=97 z=122 A=65 Z=90
   
#include <iostream>
#include <string>

using namespace std;

int main(){
   int n=0;
   //%o 八进制
   while(scanf("%x", &n)!=EOF)
  {
       printf("%d\n", n);
  }
   return 0;
}

 

posted @ 2021-09-17 08:38  kylinos-panda  阅读(107)  评论(0编辑  收藏  举报