Topic 1013: Door opener and closing man (structure custom CMP sort)

Source: Internet
Author: User

Title Link: http://ac.jobdu.com/problem.php?pid=1013

Detailed Links: https://github.com/zpfbuaa/JobduInCPlusPlus

Reference code:

////1013 Door man and closing man. CPP//Jobdu////Created by Pengfei_zheng on 28/04/2017.//copyright©2017 Pengfei_zheng. All rights reserved.//#include<stdio.h>#include<iostream>#include<algorithm>#include<string.h>#include<cstring>#include<cmath>#defineMax_size 21#defineMax_human 110using namespacestd;intN, M;structsign{CharId[max_size]; intComeh; intComem; intComeS; intlefth; intLEFTM; intlefts;}; intCmpopendoor (Const void*a,Const void*b) { Sign*c = (sign *) A; Sign*d = (sign *) b; if(C->comeh! = d->Comeh) {        returnC->comeh-d->Comeh; }    Else if(C->comem! = d->Comeh) {        returnC->comem-d->Comem; }    Else        returnC->comes-d->ComeS;} intCmpclosedoor (Const void*a,Const void*b) { Sign*c = (sign *) A; Sign*d = (sign *) b; if(C->lefth! = d->lefth) {        returnD->lefth-c->lefth; }    Else if(C-&GT;LEFTM! = d->LEFTM) {        returnD->leftm-c->LEFTM; }    Else {        returnD->lefts-c->lefts; }} sign Sign[max_human]; intMain () {//freopen ("/users/pengfei_zheng/desktop/input.txt", "R", stdin);scanf"%d",&N);  while(n--) {scanf ("%d",&m);  for(inti =0; I < m; i++) {scanf ("%s%d:%d:%d%d:%d:%d", SIGN[I].ID,&AMP;SIGN[I].COMEH,&AMP;SIGN[I].COMEM,&AMP;SIGN[I].COMES,&AMP;SIGN[I].LEFTH,&AMP;SIGN[I].LEFTM, &sign[i].lefts); } qsort (Sign,m,sizeof(sign), Cmpopendoor); printf ("%s", sign[0].id); Qsort (Sign,m,sizeof(sign), Cmpclosedoor); printf ("%s\n", sign[0].id);//for (int i = 0; i < m; i++) {//printf ("%s%d:%d:%d%d:%d:%d\n", Sign[i].id,sign[i].comeh,sign[i].comem,sign[i].comes,sign[i].lefth,sign[i] . leftm,sign[i].lefts);//        }    }}    /************************************************************** problem:1013 User:zpfbuaa language:c++ Re sult:accepted time:0 Ms memory:1524 kb****************************************************************/

Topic 1013: Door opener and closing man (structure custom CMP sort)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.