Week 2-Transcript 2 with name

Source: Internet
Author: User
/** Copyright (c) 2012, School of Computer Science, Yantai University * All Rights Reserved. * file name: test. CPP * Author: Qiu xuewei * Completion Date: July 15, December 12, 2012 * version: V1.0 * input Description: none * Problem description: (1) output the list of students sorted by score; (2) output the transcript sorted by the name of the student (the sorting object is a string ). (1) Use the array char name [] [20] to represent the names of multiple students; (2) use the strcmp and strcpy functions for comparison and replication. * Program output: * Problem Analysis: * Algorithm Design: omitted */# include <iostream> # include <string> using namespace STD; const int num = 8; int main () {Int J, I; char temp [20]; char name [num] [20] = {"Lulu", "yongyon", "Weiwei", "qiangqiang ", "Chenchen", "pengpeng", "jinjin", "Yingying"}; Double score [num] = {77,100, 89,}, T; for (j = 0; j <num-1; j ++) for (I = 0; I <num-j-1; I ++) {If (score [I] <score [I + 1]) {T = score [I]; score [I] = score [I + 1]; score [I + 1] = T; strcpy (temp, name [I]); strcpy (name [I], name [I + 1]); strcpy (name [I + 1], temp) ;}} cout <"output by score:" <Endl; for (I = 0; I <num; I ++) cout <name [I] <"\ t" <score [I] <Endl; return 0 ;}


Experience:

Comrades, the exam must pass!

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.