Simple string sorting

Source: Internet
Author: User

Simple string sorting Time limit:5000ms Memory limit:100000k Title Description

Enter the names and scores of 10 students from the keyboard, arrange the names and outputs of the students in Dictionary order (the correspondence between names and grades remains the same).

Input

Enter a total of 11 lines, the first 10 rows is a student's name, the last line is 10 spaces separated by a number of integers to indicate the corresponding 10 student scores.

Output name the names and scores of the students are listed in dictionary order, a total of 10 lines, each student's name and score of one row, the name and results separated by commas. Sample input
BUSHWHITEMARKJEANBLACKWOODJENNYFRANKBILLSMITH78 85 96 65 46 83 77 88 54 98
Sample output
bill,54black,46bush,78frank,88jean,65jenny,77mark,96smith,98white,85wood,83
Tips
Source
Sample Program
#include <iostream> #include <cstring> #include <algorithm>using namespace std;struct node{    Char NAME[10];    int grade;} STUDENT[10], T;int main () {    int i, J;    for (i=0; i<10; i++)    {        cin >> student[i].name;    }    for (i=0; i<10; i++)    {        cin >> student[i].grade;    }    For (i=0, i<9; i++) for        (j=0; j<9-i; j + +)        {            if (strcmp (student[j].name,student[j+1].name) >0)            {                t = student[j];                STUDENT[J] = student[j+1];                Student[j+1] = t;            }        }    for (i = 0; i < i++)        cout << student[i].name<< "," <<student[i].grade<<endl;    return 0;}


Simple string sorting

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.