"C + +" is done with structs: programming to find the average score of one of the 3 students

Source: Internet
Author: User

Complete with structure: programming to find the average score of a student in 3 students # include <iostream> #include <string.h>using namespace Std;struct student{ Char *name;double score[3];}; struct student stu[3]={{"Han", 80,90,95},{"Zhao", 78,85,92},{"Dan", 75,60,59}};  Initialize struct student *find (struct student *s) {char name1[20];cout<< "Please enter the name of the student you are looking for:"; cin>>name1;for (int i (0 ); i<3;i++) if (strcmp (name1,s[i].name) ==0) return s+i;cout<< "The person you are looking for does not exist." "<<endl;return 0;} int main () {struct student *p;p=find (stu);cout<<p->name<< ":" << (p->score[0]+p->score[1]+ P->SCORE[3])/3<<endl;return 0;}

"C + +" is done with structs: programming to find the average score of one of the 3 students

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.