08: Patient queuing, 08 patient queuing

Source: Internet
Author: User

08: Patient queuing, 08 patient queuing
08: Patient queuing

  • View
  • Submit
  • Statistics
  • Question
Total time limit:
1000 ms
 
Memory limit:
65536kB
Description

The procedure for registering a patient is as follows:
1. Elderly People (age> = 60 years) are given priority in seeing a doctor than non-elderly people.
2. The elderly are treated in the ascending order of age, and those of the same age are sorted by registration order.
3. non-elderly people see the doctor in the order of registration.

Input
Row 3: enter a positive integer smaller than 1st, indicating the number of patients;
The patient information is entered in each row according to the patient registration sequence, including: A string less than 10 represents the patient's ID (each patient's ID is different and only contains numbers and letters), an integer represents the patient's age, separated by a single space.
Output
Output the patient ID in the order of seeing a doctor. Each row has one.
Sample Input
5021075 40004003 15010158 67021033 75102012 30
Sample output
021033010158021075004003102012
Source
Exercise (14-6)
 1 #include<iostream> 2 #include<cstdio> 3 using namespace std; 4 struct node 5 {  6     int xh; 7     int nl; 8     char id[1001]; 9 }a[10001];10 int main()11 {12     int n;13     cin>>n;14     for(int i=1;i<=n;i++)15     {16         scanf("%s",a[i].id);17         a[i].xh=i;18         cin>>a[i].nl;19     }20     for(int i=1;i<=n;i++)21     {22         for(int j=1;j<=n-1;j++)23         {24             if((a[j].nl<60&&a[j+1].nl>=60)||(a[j].nl<60&&a[j+1].nl<60&&a[j].xh>a[j+1].xh)||(a[j].nl>=60&&a[j+1].nl>=60&&a[j].nl<a[j+1].nl)||(a[j].nl>=60&&a[j+1].nl>=60&&a[j].nl==a[j+1].nl&&a[j].xh>a[j+1].xh))25             {26                 swap(a[j].nl,a[j+1].nl);27                 swap(a[j].xh,a[j+1].xh);28                 swap(a[j].id,a[j+1].id);29             }30         }31     }32     for(int i=1;i<=n;i++)33     {34         printf("%s\n",a[i].id);35     }36     return 0;37 }

 

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.