77范文网 - 专业文章范例文档资料分享平台

C++第一至第八章课后习题答案(4)

来源:网络收集 时间:2019-06-05 下载这篇文档 手机版
说明:文章内容仅供预览,部分内容可能不全,需要完整文档或者需要复制内容,请下载word后使用。下载word有问题请添加微信号:或QQ: 处理(尽可能给您提供完整文档),感谢您的支持与谅解。点击这里给我发消息

num[j]=k;

}

cout<<\按升序排列:\ for(i=0;i<10;i++) cout<

}

13、

#include \#include using namespace std; void main(void) { int nday,nmonth,weekday,i; for(i=1;i<=212;i++) { if(i<=31) { nmonth=1;nday=i; } else if(i<=59)

{ nmonth=2;nday=i-31; } else if(i<=90)

{ nmonth=3;nday=i-59; } else if(i<=120)

{ nmonth=4;nday=i-90; } else if(i<=151)

{ nmonth=5;nday=i-120; } else if(i<=181)

{ nmonth=6;nday=i-151; } else if(i<=212)

{ nmonth=7;nday=i-181; }

//判断月份和日期

else if(i<=243)

{ nmonth=8;nday=i-212; } else if(i<=273)

{ nmonth=9;nday=i-243; } else if(i<=304)

{ nmonth=10;nday=i-273; } else if(i<=334)

{ nmonth=11;nday=i-304; } else

{ nmonth=12;nday=i-334; }

cout<<2006<<\年\月\号\

weekday=(i+1)%7; //判断星期几 } 14、

#include \#include

} return;

switch(weekday) {

case 1:cout<<\星期一\case 2:cout<<\星期二\case 3:cout<<\星期三\case 4:cout<<\星期四\case 5:cout<<\星期五\case 6:cout<<\星期六\case 0:cout<<\星期日\}

cout<

using namespace std; void main(void) { float x=0.5,s,r; int n;

for(n=1,r=1,s=1;s>1e-8;n++) //精度决定循环次数 { s=s*x/n; r+=s; }

cout<<\时近似解为\ return;

} 15、

#include \#include #include using namespace std; void main(void) {

double a,xn;

for(xn=1,a=2;abs(sqrt(a)-xn)>=1.0e-8;) {

xn=(xn+a/xn)/2; };

cout<<\的平方根为\} 16、

//每一项的迭代变化 //将每一项加和

//精度为10的-8次方 //迭代公式

#include \#include using namespace std; #define pai 3.1415926 void main(void) { double x,s,cosx; int k,i;

cout<<\请输入角度x:\ cin>>x; x=pai*x/180;

for(i=2,k=-1,s=1,cosx=1;s>=1e-8;i+=2) { s=s*x*x/(i*(i-1)); cosx+=k*s; k*=-1; }

cout<<\为:\

} 17、

#include \#include using namespace std; void main(void) { char a[256],b[256]; int i=0;

cout<<\请输入两个字符串:\ //精度为的-8次方 //求每一项

//将各项加和 //改变单位项的正负

}

cin>>a; cin>>b; while(a[i]!='\\0')

i++;

strcpy(&a[i],b); //将字符串b拷贝在a的末尾 cout<

18、

#include \#include #include using namespace std; void main(void) { } 19、

#include \#include #include

string str; int i;

cout<<\请输入字符串:\cin>>str;

for(i=0;i

cout<<\字符转变为大写:\

str[i]=toupper(str[i]);

百度搜索“77cn”或“免费范文网”即可找到本站免费阅读全部范文。收藏本站方便下次阅读,免费范文网,提供经典小说综合文库C++第一至第八章课后习题答案(4)在线全文阅读。

C++第一至第八章课后习题答案(4).doc 将本文的Word文档下载到电脑,方便复制、编辑、收藏和打印 下载失败或者文档不完整,请联系客服人员解决!
本文链接:https://www.77cn.com.cn/wenku/zonghe/649081.html(转载请注明文章来源)
Copyright © 2008-2022 免费范文网 版权所有
声明 :本网站尊重并保护知识产权,根据《信息网络传播权保护条例》,如果我们转载的作品侵犯了您的权利,请在一个月内通知我们,我们会及时删除。
客服QQ: 邮箱:tiandhx2@hotmail.com
苏ICP备16052595号-18
× 注册会员免费下载(下载后可以自由复制和排版)
注册会员下载
全站内容免费自由复制
注册会员下载
全站内容免费自由复制
注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: