B




#include <stdio.h>
#include <string.h>
#include <iostream>
#include <algorithm>
#include <stack>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <stdlib.h>
#include <time.h>
using namespace std;
#define showtime fprintf(stderr,"time = %.15f\n",clock() / (double)CLOCKS_PER_SEC)
#define lld %I64d
#define REP(i,k,n) for(int i=k;i<n;i++)
#define REPP(i,k,n) for(int i=k;i<=n;i++)
#define scan(d) scanf("%d",&d)
#define scanl(d) scanf("%I64d",&d)
#define scann(n,m) scanf("%d%d",&n,&m)
#define scannl(n,m) scanf("%I64d%I64d",&n,&m)
#define mst(a,k)  memset(a,k,sizeof(a))
#define LL long long
#define N 200001
#define MN 300005
#define mod 1000000007
struct edge{
    char name[12];
    char score[1300];
}edge[N];
bool cmp(struct edge &A,struct edge &B){
    int i=0;bool flag=false;
    while(A.score[i]!='\0'&&B.score[i]!='\0'){
        if(A.score[i]!=B.score[i]) { flag=true;return A.score[i]>B.score[i];}
        i++;
    }
    if(!flag) {
        if(A.score[i]!='\0'){
            while(A.score[i]!='\0'){
                if(A.score[i++]!='0')  return 1;
            } 
        }
        else {
            while(B.score[i]!='\0'){
                if(B.score[i++]!='0')  return 0;
            } 
        }
    }
    return  strcmp(A.name,B.name)>0?0:1;
}
int main(){
    int n;
    //std::ios::sync_with_stdio(false);
    while(~scanf("%d",&n)){
        char c=getchar();//清除掉回车
        for(int i=0;i<n;i++){
            //char c;int j=0,k=0;bool flag=false;
            cin>>edge[i].name;
            cin>>edge[i].score;
            /*
            while(~scanf("%c",&c)){
                if(c==' ') { flag=true;continue;}
                if(c!=' '&&!flag) cin<<edge[i].name[j++]=c;
                else  edge[i].score[k++]=c;
            }
            
            edge[i].name[j]='\0';
            edge[i].score[k]='\0';*/
        }
        sort(edge,edge+n,cmp);
        for(int i=0;i<n;i++){
            printf("%s",edge[i].name);
            printf(" ");
            printf("%s",edge[i].score);
            printf("\n");
        }
    }
    return 0;
}


猜你喜欢

转载自blog.csdn.net/qq_33890670/article/details/79934710
B
a^b
A/B
A*B