Week 2 project 2-ordered struct Array

Source: Internet
Author: User

/** Copyright and version statement of the program: * Copyright (c) 2013, student * All rights reserved from computer College of Yantai University. * file name: * Author: Zhang Kai * Completion Date: July 15, March 9, 2013 * version: v1.0 * description of the task and solution section: * input Description: none * Problem description: calculate student data * program output: Student Achievement * Problem Analysis: * Algorithm Design: */# include
 
  
# Include
  
   
# Include
   
    
Using namespace std; struct Student {char num [13]; char name [10]; int cpp; int math; int english; int grade; double average ;}; void calculate (Student s [], int n); // calculate the total score and average score. Data in the s array has n elements void sort1 (Student [], int ); // sort void sort2 (Student [], int) in descending order of the total score; // sort void output (Student [], int) in ascending order of Student IDs ); // output transcript void outputExcellent (Student [], int); // output excellent: total score over 285, single subject no less than 90int main () {Student stu [] = {"201152501104", "Tom", 201152501114, 68}, {"", "Jeery", 94, 89, 63 }, {"201152501138", "Speike", 67, 62, 84 },{ "201152501204", "Tyke", 100, 95, 91 },{ "201152501202 ", "Tuffy", 59, 80, 55 },{ "201152501115", "Butch", 100, 99, 89 },{ "201152501201", "Lightning", 95, 92, 99 },{ "201152501145", "Topsy", 88, 56, 67 },{ "201152501203", "Droopy", 62, 62, 95 },{ "201152501140 ", "Drupa", 80, 60, 86 },{ "201152501205", "Buzz", 73, 90, 94 }}; int stuNum = sizeof (stu) /sizeof (stu [0]); // use the sizeof operation to determine the number of elements in the array // calculate the total score and the average score and output calculate (stu, stuNum ); cout <"The following is the transcript:" <
    
     
S [k + 1]. grade) {t = s [k]; s [k] = s [k + 1]; s [k + 1] = t ;}} void sort2 (Student s [], int n) // sort by Student ID in ascending order {int I, j; Student t; for (I = 0; I
     
      
285 & s [I]. cpp> = 90 & s [I]. math> = 90 & s [I]. english> = 90) {cout <
      
       

Running result


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.