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;
}
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;
}
相关文章推荐
- Qt调用dll中的功能函数
- 具名函数的四种调用方式(1)
- gcc 函数调用探测功能
- Qt调用dll中的功能函数
- Qt调用dll中的功能函数
- C++中函数调用时的三种参数传递方式
- 几种函数调用方式
- CALLBACK, WINAPI, AFXAPI和函数调用方式
- C/C++:函数的编译方式与调用约定以及extern “C”的使用
- 函数调用三种方式:传值&传引用&传指针
- 函数调用方式--__thiscall调用方式和__cdecl,__stdcall有什么区别
- 函数调用方式
- MySQL存储过程和自定义函数、Navicat、创建存储过程和函数、调用存储过程和函数、三种方式、In和Out类型参数、
- 使用sqlite3的接口函数完成一个用户登录验证功能模块设计 要封装成独立函数,在独立的main中调用测试;
- js自执行函数及参照jquery调用方法方式
- 设计基于HTML5的APP登录功能及安全调用接口的方式
- flatMap功能不只是wordcount,不知不觉用flatmap实现了hive的自带函数explode功能
- Android 系统调用实现函数功能--SVC指令的实现与检测
- 定义一个一维数组,写以下6个函数来完成相应功能,在主函数中调用这6个函数。(要求,函数形参都为指针变量)
- C++ 函数调用方式(_stdcall, _pascal, _cdecl...)总结