您的位置:首页 > 其它

7--4(和7--3的功能一样,只是用函数调用方式)

2013-03-20 20:31 218 查看
#include<iostream>

using namespace std;

struct Score/*----------------------------------------定义结构体变量*/

{

int a;

int b;

int c;

};

struct Student

{

int a;/*-----------------------学号*/

char b[20];/*------------------姓名*/

Score c;/*---------------------成绩*/

}s;/*-------------------------------------------------定义结构体变量*/

int main()

{

void print(Student *p);

Student *p=&s;

cout<<"请按\"学号\",\"姓名\",\"成绩(语数外)\"输入."<<endl<<"请输入";

print(&s);

return 0;

}

void print(Student *p)

{

void input(Student *p);

int SUM(Student *p);

double a;

input(&s);

a=SUM(&s);

cout<<"学号 "<<s.a<<endl;

cout<<"姓名 "<<s.b<<endl;

cout<<"语文 "<<s.c.a<<endl;

cout<<"数学 "<<s.c.b<<" 总成绩 平均成绩"<<endl;

cout<<"外语 "<<s.c.c<<" "<<a<<" "<<a/3.0<<endl;

}

void input(Student *p)

{

cin>>p->a>>p->b>>p->c.a>>p->c.b>>p->c.c;

}

int SUM(Student *p)

{

int a;

a=p->c.a+p->c.b+p->c.c;

return a;

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: