下载此文档

employee人员类实验报告.doc


文档分类:汽车/机械/制造 | 页数:约6页 举报非法文档有奖
1/6
下载提示
  • 1.该资料是网友上传的,本站提供全文预览,预览什么样,下载就什么样。
  • 2.下载该文档所得收入归上传者、原创者。
  • 3.下载的文档,不会出现我们的网址水印。
1/6 下载此文档
文档列表 文档介绍
C++及其编程思想
实验报告
学号:
姓名:
班级:
日期: .
实验目的:
、定义和调用的方法;


++的debug调试功能,使用step into追踪到函数内部。
实验内容及完成情况:
,两个双精度数的最大值,并在main()函数中测试函数功能.
#include<iostream>
using namespace std;
int max(int a,int b);
double max(double a,double b);
int main()
{
int i1,i2,i;
cout<<"输入两个整数:\n";
cin>>i1>>i2;
i=max(i1,i2);
cout<<"i_max="<<i<<endl;
cout<<"输入两个双精度数:\n";
double d1,d2,d;
cin>>d1>>d2;
d=max(d1,d2);
cout<<"d_max="<<d<<endl;
return 0;
}
int max(int a,int b)
{
if(b>a)
a=b;
return a;
}
double max(double a,double b)
{
if(b>a)
a=b;
return a;
}
调试过程中的错误、原因及解决办法:
在进行中英文切换过程中,出现打印代码时使用中文调试出现错误;
在进行求两个双精度数的最大值时,忘记了输入语句,致使结果是随机值。
,每个学生修了三门课,1)求每个学生的平均成绩,并输出每个学生的学号,姓名,每门课程的成绩及平均值。2)求某门课程的平均分;
要求:
1、分别编写2个函数实现以上2个要求。
2、第1个函数用数组名作参数。第2个函数用指针用参数,并在函数体内用指针对数组操作。
3. 姓名字段采用string类型或字符数
#include<iostream>
#include<iomanip>
using namespace std;
struct student
{
int num;
char name[20];
float score[3];
float aver;
};
void put(struct student stu[]);
void out_average1(struct student stu[]);
void out_average2(struct student *p);
int main()
{
struct student stu[5],*p;
p=stu;
put(stu);
out_average1(stu);
out_average2(p);
return 0;
}
void put(struct student stu[ ])
{
int i;
for(i=0;i<5;i++)
{
cout<<"please enter the"<<i+1<<"th student's nu

employee人员类实验报告 来自淘豆网m.daumloan.com转载请标明出处.

非法内容举报中心
文档信息
  • 页数6
  • 收藏数0 收藏
  • 顶次数0
  • 上传人mh900965
  • 文件大小493 KB
  • 时间2018-04-28