PAT乙级 人口普查(20)

状态不好了,就不应该继续刷......

连一个简单的排序都写不好......

#include "iostream"
#include "stdio.h"
#include "string"
#include "string.h"
#include "map"
#include "vector"
#include "algorithm"
using namespace std;

struct year
{
	int y,m,d;
	char name[20];
};

bool comp(const year &a,const year &b)
{
	if(a.y == b.y&&a.m == b.m)
		return a.d>b.d;
	else if(a.y==b.y)
		return a.m>b.m;
	else
		return a.y>b.y;
}

int main()
{
	int num;
	int i,j;
	int old,young,resultnum;
	cin>>num;
	int temp = num;
	resultnum = num;
	year tempy;
	char temps[20];
	vector result;
	i = 0;
	
	while(temp--)
	{
		scanf("%s",tempy.name);
		scanf("%d/%d/%d",&tempy.y,&tempy.m,&tempy.d);
		result.push_back(tempy);
	}

	sort(result.begin(),result.end(),comp);


	//2014 09 06

	for(i=0;i=0;i--)
	{
		if((result[i].y>1814)||(result[i].y==1814&&result[i].m>9)||(result[i].y==1814&&result[i].m==9&&result[i].d>=6))
		{	
			old = i;
			break;
		}
		resultnum--;
		
	}

	cout<


你可能感兴趣的:(数据结构算法学习)