Noip2011-Universal group semi-final simulation test-first title-nba Championship

Source: Internet
Author: User

Topic Background Background

A two-year final exam is coming!! Title Description DescriptionAgain to the exam, LJW decided to relax, turned on the TV, saw the basketball game, he immediately thought of the annual NBA Championship team.  As a result of the review of tension, he only remembers part of the content of the memory is correct, may not be in chronological order, the contents of the memory may be duplicated.  Now ask to learn programming you help LJW, the team that outputs the championship in chronological order (cannot be duplicated). (NBA from 1947A.D to 2009A.D) input/output format input/output Input Format:
The first line of the input file nba.in is an integer n (0<n<50). The next n rows, each row is the city name (composed of uppercase and lowercase letters, spaces), followed by time (composed of numbers), separated by a space.
output Format:
Output file Nba.out A total of n rows, that is, after the ranking of the NBA championship team. Every first time, then the city name. input and Output sample sample Input/output sample Test point # #

Input sample (nba.in):

3

Boston 1963

Boston 1959

Philly 1947

Output Example (nba.out):

1947 Philly

1959 Boston

1963 Boston

Thought: No time, next time to write, first on the code

The code is as follows:

1#include <stdio.h>2#include <string.h>3 structStu4 {5     Charnum[ -];6     intscore;7 };8 intMain ()9 {Ten     intn,i,j,max=0, kk,flag,shuzi[ -],aaaaa='a', ll=-1; One     structStu a[ the],t;  A     //freopen ("nba.in", "R", stdin); -     //freopen ("Nba.out", "w", stdout);  -scanf"%d",&n); the      for(i=0; i<n;i++) -     { -ll++; -max=0; +j=0; -scanf"%c",&aaaaa); +          while(aaaaa!='\ n') A         { at              -             if(aaaaa>='0'&&aaaaa<='9')//is a number -             { -shuzi[j]=aaaaa; -J + +; -             }    in             Else //is the letter -             { toa[i].num[max]=aaaaa; +max++; -             } thescanf"%c",&aaaaa); *         } $a[i].num[max]=' /';Panax NotoginsengA[ll].score=0; -          for(kk=0; kk<j;kk++)//Conversion Numbers the         { +a[ll].score=a[ll].score*Ten+shuzi[kk]-'0'; A         }         the     }    +      for(i=1; i<n;i++) -     { $flag=1; $          for(j=0; j<n-i;j++)//Sort -         { -             if(a[j].score>a[j+1].score) the             { -flag=0;Wuyit=A[j]; thea[j]=a[j+1]; -a[j+1]=T; Wu             } -         } About         if(flag) Break;  $     } -printf"\ n"); -      for(i=0; i<n;i++) -     { A         if(a[i].score!=a[i+1].score| | strcmp (a[i].num,a[i+1].num)! =0) +         { theprintf"%d%s\n", a[i].score,a[i].num); -         }         $     }     the     return 0; the}

Noip2011-Universal group semi-final simulation test-first title-nba Championship

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.