- 1、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。。
- 2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 3、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
C上机实验报告实验一概要
实验一
Exercise 1
1.实验目的
1.熟悉Microsoft Visual C++6.0集成开发环境
2.学习创建控制台应用程序项目
3.编辑源程序
4.编译和调试程序
2.实验要求
1.熟悉程序开发环境
2.编辑源程序
3.编译并调试程序
3.实验内容
1.熟悉Microsoft Visual Studio 6.0 的开发环境
2.编辑并调试下面的程序
注:工程中的文件包括三个:TimeType.h、TimeType.cpp、Diary.cpp
4.源程序
class TimeType{
public:
void Set(int hours,int minutes,int seconds);
void Increment();
void Write();// const;
bool Euqal(TimeType otherTime) ;//const;
bool LessThan(TimeType otherTime);//const;
private:
int hrs;
int mins;
int secs;
};
#includeTimeType.h
#includeiostream
using namespace std;
void TimeType::Set(int hours,int minutes,int seconds)
{
hrs=hours;
mins=minutes;
secs=seconds;
}//Set()
void TimeType::Increment()
{
secs++;
if(secs59){
secs=0;
mins++;
if(mins59){
mins=0;
hrs++;
if(hrs23) hrs=0;
}
}
}//Increment()
void TimeType::Write() //const
{
couthrs:;
if(mins10) cout0;
coutmins:;
if(secs10) cout0;
coutsecs;
}//Write()
bool TimeType::Euqal(TimeType otherTime)//const
{
return(hrs==otherTime.hrsmins==otherTime.minssecs==otherTime.secs);
}
bool TimeType::LessThan(TimeType otherTime)//const
{
return(hrsotherTime.hrs||hrs==otherTime.hrsminsotherTime.mins||hrs==otherTime.hrsmins==otherTime.minssecsotherTime.secs);
}
#includeiostream
#includeTimeType.h
using namespace std;
int main()
{
TimeType time;
TimeType othertime;
int hours;
int minutes;
int seconds;
coutEnter a time (use hours0 to quit):;
cinhoursminutesseconds;
while(hours=0)//while(hours=0)
{
time.Set(hours,minutes,seconds);
time.Increment();//设置时间量
coutIncremented time is;
time.Write();//输出时间
coutendl;
coutEnter a time(use hours0 to quit):;
cinhoursminutesseconds;//输入另一个时间量
othertime.Set(hours,minutes,seconds);
if(time.Euqal(othertime))//判断两个时间的大小关系
couttime is equal to othertimeendl;
else if(time.LessThan(othertime))
couttime is lessthan to othertimeendl;
else couttime is morethan to othertimeendl;
}//while
return 0;
}
5.运行结果
1.创建工程和文件
2.调试时间程序
6.心得体会
通过练习一,进一步了解了Microsoft
您可能关注的文档
- book6_module3_introductionandlistening.ppt
- boost常用库的使用介绍第一讲.ppt
- BPSMethodpackages.ppt
- BOSS系统介绍.ppt
- BRCSGS检验标准.ppt
- BRC仓储标准培训.ppt
- BS-QP-11产品检验控制程序.doc
- Bob_Dylan鲍勃·迪伦_英文介绍.ppt
- BS三年级上册语文半期知识点.doc
- BMW技术亮点和附件介绍.ppt
- Unit2ExploringtheTopicThinkingSkillsReadingStrategies课件仁爱科普版英语八年级上册.pptx
- Unit2Goforit!Lesson2Understandingideas(Reading)课件-外研版英语七年级下册.pptx
- Unit2ExploringEnglishUnderstandingideas课件-高中英语外研版.pptx
- Unit2DifferentfamiliesPartA(课件)-人教PEP版英语三年级上册_1.pptx
- Unit2Intown第三课时(课件)-Joinin外研剑桥英语四年级上册.pptx
- Unit2Ithinkthatmooncakesaredelicious!SectionA3a-3c课件人教版英语九年级全册.pptx
- Unit2HealthyLifestyleReadingandThinking课件-高中英语人教版选择性_1.pptx
- Unit2HomeSweetHomeSectionB(1a1e)课件-人教版英语八年级上册.pptx
- Unit2GrammarFocus3a-3c课件人教版(2024)八年级英语上册.pptx
- Unit2DevelopingideasListeningandspeaking课件-外研版七年级英语下册.pptx
最近下载
- 卫生毒理学课件.pptx VIP
- 中医治未病技术操作规范 体质调理.pdf
- 创作具有幽默和讽刺的作品.pptx VIP
- 2025鄂尔多斯市东胜区市场监督管理局食品安全协管员面向社会公开招聘笔试备考题库及答案解析.docx VIP
- 2025执业药师继续教育《中国高血压防治指南(2024年修订版)》解读:分级分期分型与精准防治(2)参考答案.docx
- 2020年度CSNA笔试题库含答案.pdf VIP
- 托管老师兼职劳务合同8篇.docx VIP
- 创作具有幽默和讽刺的作品.pptx VIP
- 大跨度钢管混凝土拱桥的施工方法.pdf VIP
- YYT1437-2023 医疗器械 GBT42062应用指南.pdf VIP
文档评论(0)