ImageVerifierCode 换一换
格式:DOCX , 页数:26 ,大小:416.87KB ,
资源ID:18113496      下载积分:3 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bdocx.com/down/18113496.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(西安交大C++程序设计第十一章作业教学提纲Word下载.docx)为本站会员(b****6)主动上传,冰豆网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰豆网(发送邮件至service@bdocx.com或直接QQ联系客服),我们立即给予删除!

西安交大C++程序设计第十一章作业教学提纲Word下载.docx

1、(1)域宽不够时会自动补足。(2)精度只需一次定义则一直有效。(3)域宽需要每次输出时均进行定义(二)第二题: 编写一个程序,将华氏温度0度212度转化为浮点型摄氏温度,浮点精度为3.转换公式为如下:Celsius=5.0/9.0*(Fahrenheit-32);输出用两个右对齐序列,摄氏温度前面加上正负号。1. 源程序代码: double Celsius,Fahrenheit; cout.precision(3);转换结果为: for(Fahrenheit=0;Fahrenheit=212;Fahrenheit+) cout.unsetf(ios:showpos); Celsius=5.0/

2、9.0*(Fahrenheit-32);华氏度=摄氏 cout.setf(ios:Celsius度n (三)第三题: 编写一个程序,打印出ASC字符集中码值为33126的字符的ASC码表。要求输出十进制值、八进制值、十六进制值以及码值所表示的字符。 int a; char w;字符 八进制 十进制 十六进制n for(a=33;a=126;a+) w=a;wtoctdechex运算符,使其能够直接使用cin语句输入Date类对象。/ 日期类定义date.h#ifndef DATE_H#define DATE_H#include class Date friend ostream &operat

3、or(istream &,Date & int day,month,year; void IncDay(); /日期增加一天 int DayCalc() const; /距基准日期的天数 static const int days; /每月的天数public: Date( int y, int m, int d); /构造函数 Date( int m, int d); /构造函数,年默认为系统当前年份 Date(); /构造函数,默认为系统日期 void SystemDate(); void SetDate( int yy, int mm, int dd ); /日期设置 void SetDa

4、te( int mm, int dd ); /日期设置,年默认为系统年份 bool IsLeapYear(int yy) const; / 是否闰年? bool IsEndofMonth() const; / 是否月末? void print_ymd() const; /输出日期yy_mm_dd void print_mdy() const; /输出日期mm_dd_yy const Date &operator+(int days); / 日期增加任意天operator+=(int days); int operator-(const Date& ymd)const; / 两个日期之间的天数

5、void Show(Date& da);#endif/ Date类成员函数定义date.cpptime.h#include date.hconst int Date:days = 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 ;/构造函数Date:Date(int y,int m,int d) SetDate(y,m,d);Date(int m,int d) SetDate(m,d);Date() SystemDate();void Date:SystemDate() /取得系统日期 tm *gm; time_t t=time(NULL);

6、 gm = gmtime(&t); year = 1900 + gm-tm_year; month = gm-tm_mon +1; day = gm-tm_mday;SetDate( int yy, int mm, int dd ) month = ( mm = 1 & mm = 1900 & yy dd = 29 ) ? dd : else= days month ) ?SetDate(int mm, int dd )const Date &operator+( int days ) /重载+ for ( int i = 0; i days; i+ ) IncDay(); return *t

7、his;operator+=( int days ) /重载+=int Date:operator-(const Date& ymd )const /重载- int days; days = DayCalc()-ymd.DayCalc(); return days;bool Date:IsLeapYear( int y ) const if ( y % 400 = 0 | ( y % 100 != 0 & y % 4 = 0 ) ) return true; return false;IsEndofMonth() const return day = 29; /二月需要判断是否闰年 retur

8、n day = days month ;IncDay() /日期递增一天 if ( IsEndofMonth() if (month = 12) / 年末 day = 1; month = 1; year+; else / 月末 month+; else day+;DayCalc() const int dd; int yy = year - 1900; dd = yy*365; if(yy) dd += (yy-1)/4; for(int i=1;i2) dd+; dd += day; return dd;print_ymd() const cout year - month day end

9、l;print_mdy() const char *monthName 12 = January, February, MarchAprilMayJuneJulyAugustSeptemberOctoberNovemberDecember ; monthName month-1 Show(Date& da) if(day=da.day&month=da.month)Happy Birthday! if(da-Date:Date()0) da.year+;It will be your birthday after da-Date: days!ostream &output,const Date

10、 &d) static char *monthName12= outputmonthNamed.month-1d.dayabc; d.year=a; d.month=b; d.day=c; return in;/main.cpp修改例-9中的程序,重载int main() Date today,Olympicday(2004,8,13);Today (the computers day) is:today/ today += 365;After 365 days, the date is: Date testday(2,28);the test date is:testday Date nex

11、tday = testday + 1;the next date is: today.SystemDate();the Athens Olympic Games openday is:Olympicdaybirthday;输入的是:birthdaystring string s,name,name1;请输入源c+文件的名称(不含有后缀名):name; name1=name+.prn name+=.cpp ifstream read(name.c_str();/读取的文件,用name.c_str()是将string 的char *类型转换成const的类型,不然会出错 fstream write

12、; write.open(name1.c_str(),ios:trunc/*创建文件*/|ios:out/*写文件*/);/输出的文件,创建文件并写文件 int i=0; if(!read)Cannot open input filen return 0; /如果打开输入文件失败write)Cannot open output filen /如果打开输出文件失败 while (getline(read,s)/逐行读取文件中数据到字符串s中 write+is/输出读取文件的信息到目标文件 read.close(); write.close();/关闭文件目标文件生成成功!(和源文件同目录)实验前

13、:实验后:六、第六题:将一个文本文件内容用凯撒尔方法加密,密钥是4。即文本文件中字母用其后第4个字母代替,若是数字则用其后第4个数字代替。例如文本文件原内容为“Red And Black 2008”,加密后文本文件内容为“Vih Erh Fpego 6442”。(提示:先用记事本创建一个文本文件,其内容应该是有意义的英文句子,然后以只读方式打开,加密后的内容写入另一个文本文件中。)char jiami(char ch); ifstream in(test.txt ofstream out(test_1.txtin)Can not open the file. return 1;out) cha

14、r ch; while(in) in.get(ch); ch=jiami(ch); if(in)out=0ch5)ch=ch-6; else ch+=4; else if(chazw)ch=ch+4-+-1;AZW return ch;加密前:加密后:(七)第七题: (必作题)找出100以内的勾股数,输出到文件gouku中。所谓勾股数指找出三个数满足A2+B2=C2,并且ABgougu.txtCan not open the file.n for(int i=0;101; for(int j=i+1;jj+) for(int k=j+1;kk+) if(i*i+j*j=k*k) out.set

15、f(ios:left); outsetw(3)k;t2 2. 实验结果: (八)第八题:仿造实现DOS文件复制命令COPY 源文件名 目标文件名。利用main()函数中的参数int argv,char *argk 识别解析命令。int main(int argc, char*argv) argc; if (argc != 3) cout 请输入两个文件名,及后缀 ifstream fin(argv1, ios:binary | ios:in); if (!fin)无法打开原文件 ofstream fout(argv2, ios:out);fout)无法打开目标文件 while (fin) fin.get(ch); if (fin) fout ch; fin.close(); fout.close();保存为exe格式之后提示“64位不兼容”,由于能力有限不知道如何操作。因而无法得到结果。

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1