1 / 15
文档名称:

《面向对象程序设计》实验报告[二].docx

格式:docx   大小:102KB   页数:15页
下载后只包含 1 个 DOCX 格式的文档,没有任何的图纸或源代码,查看文件列表

如果您已付费下载过本站文档,您可以点这里二次下载

分享

预览

《面向对象程序设计》实验报告[二].docx

上传人:小博士 2022/6/5 文件大小:102 KB

下载得到文件列表

《面向对象程序设计》实验报告[二].docx

文档介绍

文档介绍:我展Z宛伏#
计算机科学与工程学院
《面向对象程序设计》实验报告[二]
专业班级
2017数字媒体技术01
实验地点
J411
学生学号
1705121411
指导教师
陈艳
学生姓名
黄浩博
实验时间
ouble len; Ien=a+b+c; return len;
}
double Triangle::Area()( double p= (a+b+c)/2; doubIe s=sqrt (p*(p-a)*(p-b)*(p-c)); return s;
} 题目2: #i ncIude<iostream> class Square( private:
■ 1 D:\codeblocks\K;fi^\text\bin\Debug\€
double m_a;
pub Iic:
This project Please enter The square's The square5 s The square's Bye
is about square!
the square's length:3 length is:3
Perimeter is : 12
Area is :9
Square ();
"Square ();
vo i d Set (doub lea);
vo i d Get ();
double Perimeter ();
double AreaO ;
};
int ma i n () (
Square square;
enter
the square's Iength:";
std:: cout«"P I ease
double a, b, c;
std:: c i n»a;
(a);
square. Get ();
b=square. Perimeter ();
c=square. Area ();
Perimeter is : "«b«std::end I Area i s : "«c«std: : end I ;
std::cout«"The square's
«"The square's
return 0;
}
Square: :Square() (
is about square! "«std: : end I ;
std::cout«"This project } Square::"Square() (
std::cout«"Bye~~"«std::end I;
}
void Square::Set (double a) ( m_a=a;
}
void Square::Get () (
std:: cout«"The square' s I ength i s: "«m_a«std:: end I; }
double Square::Perimeter()(
return 4*m_a;
}
double Square: :Area() ( return m_a*m_a;
}
题目3:
■J D:\codeblocks\代码\text\bin\Debug\
This is a new time.
This is a new time.
Please enter the time in chronological order. Please enter the time:(second minute, hour)
50 30 2
Please enter the time:(second minute, hour)
10 21 5
The time interval is:(hour, minute, second) 2 hours, 50 minutes20 seconds. End...
End...
End...
#i ncIude<iostream>
class Time(
private:
int m_hour, m_mi nute, m_second;
pub Iic:
TimeO {std: : cout«"This is a new time. "«std:: end I ;};
void Set(int s, int m, int h){m_hour=h;m_minute=m;m_second=s;};
void Interval (Time s);
^TimeO {std::cout«"End... "«std: :end I;};
};
int ma i n () (
Time time[2];
std:: cout«"P I ease enter the t