1300 competition Registration

Source: Internet
Author: User


Beijing airlines will hold the fourth Program Design Competition. contestants can register online. However, some students may enter another registration form due to incorrect information during registration, which may cause some trouble for the participating organizers. So the competition organizer thoughtCount the number of registrants per studentTo manually check the registration information.


This question contains multiple groups of test data. The maximum number of first-row registration numbers, which can be 1000. Next, each row has a student ID, which is an eight-digit student ID for Beihang undergraduates. The input data ends with 0.


Input data for each group,The first occurrence order of the student ID in the input dataAnd the number of occurrences of the student ID, which are separated by spaces.There is a blank line between each two groups of data..

Example input 7
0 sample output

35211312 1
36211625 3
35211425 3

35211425 2

This is a simulated question. The student ID that appears for the first time is recorded and stored in an array. Then, the student ID that appears later is compared with the student ID in the array to determine the number of times.


#include<stdio.h>#include<string.h>main(){int te;int number;int i,j;char a[1000][100];int count[1000];scanf("%d",&number);getchar();while(number!=0){for(i=0;i<1000;i++)count[i]=0;for(te=0;te<number;te++){   scanf("%s",&a[te]);}for(i=0;i<number;i++)for(j=i+1;j<number;j++)if(strcmp(a[i],a[j])==0&&a[j][0]!='*'&&a[i][0]!='*'){ count[i]++;   a[j][0]='*';}for(i=0;i<number;i++){ if(a[i][0]!='*'){  for(j=0;a[i][j]!='\0';j++)     printf("%c",a[i][j]);   printf(" %d\n",count[i]+1);}}           printf("\n");scanf("%d",&number);getchar();}}


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.