Sdut exercise 8 Object-oriented programming (an array of objects)

Source: Internet
Author: User
On-Machine Exercise 8 Object-oriented programming (an array of objects) Time limit:1000ms Memory limit:65536k The title description uses an array of class objects to complete the input and output of n student data (number is string type, Grade is integer). Input input has n+1 line:
The integer n of the first line indicates the number of students;
The following n rows are data for n students, the first in each row is a string representing the number of students, and the second is an integer representing the student's score. Output output n student data.

One row for each student's data.

Demo sample Input

501 8902 7803 5604 9205 76
Demo sample Output
01 8902 7803 5604 9205 76
Cue source ZLH Demo sample Program

C + + Object array So, how to say it, use it flexibly. Anyway the code is a look can be clear.

#include <iostream> #include <string>using namespace Std;class student{private:    string i;    int g;public:void in () {cin >> I >> g;} void out () {cout << i << "" << g << Endl;}}; int main () {int n,i;student stu[500];cin>>n;for (i=0;i<n;i++) stu[i].in (); for (i=0;i<n;i++) stu[i].out (); return 0;}

Copyright notice: This article blog original article. Blogs, without consent, may not be reproduced.

Sdut exercise 8 Object-oriented programming (an array of objects)

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.