C++STL

#include<map>
#include<set>
#include<queue>
#include<stack>
#include<deque>
#include<vector>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;

#define rep(x) for (int i=0;i<x;i++) 
#define repc(c) for (typeof(c.begin()) i=c.begin();i!=c.end();i++)
#define pb push_back

struct test
{
	int x,y;
	bool operator <(const test& other) const
	{
		return x<other.x || (x==other.x && y<other.y);
	}
	bool operator ==(const test& other) const
	{
		return x==other.x && y==other.y; 
	}
};

test a[1000];
vector<test> v;
set<test> s;
priority_queue<test> q;
map<test,int> m;
int n,idx;

void input()
{
	scanf("%d\n",&n);
	rep(n) scanf("%d %d\n",&a[i].x,&a[i].y);
}

void output()
{
	rep(n) printf("%d %d\n",a[i].x,a[i].y);
	printf("-------\n");
}



int main()
{
	freopen("test.in","r",stdin);
	freopen("test.out","w",stdout);
	
	input();
	
	/*------sort------*/
	
	/*
	sort(a,a+n);
	output();
	*/
	
	/*------vector------*/
	
	/*
	rep(n) v.pb(a[i]);
	repc(v) printf("%d %d\n",i->x,i->y);
	*/
	
	/*------priority_queue------*/
	
	/* 
	rep(n) q.push(a[i]);
	while (!q.empty())
	{
		printf("%d %d\n",q.top().x,q.top().y);
		q.pop();
	}
	*/

	/*------set------*/
	
	/*
	rep(n) s.insert(a[i]);
	repc(s) printf("%d %d\n",i->x,i->y);
	*/
	
	/*------map------*/
	
	/*
	idx=0; 
	rep(n) if (m[a[i]]==0) m[a[i]]=++idx;
	rep(n) printf("%d\n",m[a[i]]);
	*/
	
	
	return 0;
}

  

原文链接: https://www.cnblogs.com/exponent/archive/2012/11/09/2762031.html

欢迎关注

微信关注下方公众号,第一时间获取干货硬货;公众号内回复【pdf】免费获取数百本计算机经典书籍

    C++STL

原创文章受到原创版权保护。转载请注明出处:https://www.ccppcoding.com/archives/68728

非原创文章文中已经注明原地址,如有侵权,联系删除

关注公众号【高性能架构探索】,第一时间获取最新文章

转载文章受原作者版权保护。转载请注明原作者出处!

(0)
上一篇 2023年2月9日 下午1:28
下一篇 2023年2月9日 下午1:28

相关推荐