ACM 头文件

 

包括:

重载运算符(输出、加减)

去重unique

利用sstream进行 转换

#include<cstdio>
#include<iostream>
#include<vector>
#include<string>
#include<map>
#include<cstring>
#include<set>
#include<cmath>
#include<queue>
#include<sstream>
#include<algorithm>
#define rep(i,j,k) for(int i=j;i<k;++i)
#define mst(a,b) memset((a),(b),sizeof(a))
#include<cstring>
#define fi first
#define se second
#define ALL(v) (v).begin(),(v).end()
#define SORT(v) sort(ALL(v))
#define vunique(v) unique(ALL(v))
#define mp(a,b) make_pair(a,b)
using namespace std;
typedef long long LL;
typedef vector<int,int> vii;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;
pll operator+(pll a, pll b) {return pll(a.fi+b.fi,a.se+b.se);}
pll operator-(pll a, pll b) {return pll(a.fi-b.fi,a.se-b.se);}
ostream &operator<<(ostream & out, pll a){out << a.fi << " " << a.se;}
string int2str(LL a){ostringstream os;os.str(""); os << a; return os.str();} // 转换前 清空流
LL str2int(string a){LL n;stringstream ss; ss.clear();ss << a; ss >> n; return n;}

int main()
	{
	    /*
            去重方法
	    */
	    int a[] =  {10,20,20,20,30,30,20,20,10};
        vector<int> vec(a,a+9);
        SORT(vec);
        std::vector<int>::iterator it = vunique(vec);
        vec.resize(std::distance(vec.begin(),it));
        cout << std::distance(vec.begin(),it) <<endl;
        rep(i,0,vec.size()){
            cout << vec[i] << " ";
        }
        cout << endl;
        /*
            重载运算符
        */
        pll c =  mp(1,2);
        pll d = mp(3,4);
        pll e = c+d;
        cout << e  << endl;

        /*
            利用 stringstream 进行 int 与 string 转换 需要 头文件 sstream
        */
        LL n = str2int("123456789");
        string str = int2str(12313134131);
        cout << n << endl;
        cout << str << endl;

		return 0;
	}

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值