- 1、本文档共110页,可阅读全部内容。
- 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
- 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
2016.4.22上机内容
2016.4.22 #includeiostream using namespace std; void main( ){ cout123456781234567812345678endl; cout1\t35\t22endl ; cout123\t3\t222endl ; } 下面是上节课讲的内容 附加题 检测你前面学过的内容。 注意 一定要先做再验证,才有效果。 #includeiostream using namespace std; void main( ){ int a=3,b=5; a=a^b; b=b^a; a=a^b; couta=a b=bendl; } #includeiostream using namespace std; void main( ){ cout94endl; cout(94)endl; } #includeiostream using namespace std; void main( ){ cout(34 27)endl; } #includeiostream using namespace std; void main( ){ cout( -12 2 )endl; } #includeiostream using namespace std; void main( ){ cout( 26 |14 )endl; } #includeiostream using namespace std; void main( ){ cout( 18 ^22 )endl; } * * * * 修改返回类型 #include iostream using namespace std; //计算x的n次方 int power (double x, int n) { double val = 1.0; while (n--) val = val*x; return(val); } int main( ) { cout 5.6 to the power 2 is power(5.6,2) endl; return 0; } * 注意:不要这样做 * * #include iostream using namespace std; double power (double x, int n); void main( ) { cout 5 to the power 2 is power(5,2) endl; } double power (double x, int n) { double val = 1.0; while (n--) val = val*x; return(val); } * * //double power (double x, int n); 如果屏蔽这一句,编译出错。 error C2065: power : undeclared identifier * * 例3-2 数制转换 题目: 输入一个8位二进制数,将其转换为十进制数输出。 例如 11012 = 1*(23) + 1*(22) + 0*(21) + 1*(20) = 1310 所以,如果输入1101,则应输出13 * #include iostream using namespace std; double power (double x, int n); int main( ) { int value = 0; cout Enter an 8 bit binary number ; for (int i = 7; i = 0; i--) { char ch; cin ch; if (ch == 1) value += static_castint(power(2,i)); } cout Decimal value is valueendl; return 0; } double power (double x, int n) { double val = 1.0; while (n--) val *= x; return(val); } * * * 也可以这样写 if (ch == 1) value += int (power(2,i)); if (ch == 1) value += static_castint(power(2,i)); * * 读程序
您可能关注的文档
- 2015生物中考试题分类——人体通过神经系统和内分泌系统调节生命活动.doc
- 2015物理中考复习课件(八至九年级全册).ppt
- 2015电子技术课设大纲及任务要_....doc
- 2015电力电子技术研究热点探索.doc
- 2015电子大赛试题.doc
- 2015电学实验1.doc
- 2015生物联赛辅导——细胞生物学.ppt
- 2015百度索引量下降的解决方法.ppt
- 2015甘肃省教科所高考研讨会高考趋势分析及备考策略(银涛)PPT.ppt
- 2015短学期综合程序设计.doc
- 高考政治一轮复习必修2经济与社会专题二第六课我国的社会主义市场经济体制突破主观题型关于“社会主义市场经济”的措施类课件.pptx
- 高考政治一轮复习选择性必修3逻辑与思维专题十二逻辑与思维第三十六课运用辩证思维方法突破主观题型关于“辩证思维”的分析类课件.pptx
- Unit 3 Sports and fitness language points of reading and thinking 英语教学课件.pptx
- Vicor-高带宽电源模块消除高压线路纹波抑制的干扰.docx
- 六合理化建议.docx
- 4种高性能隔离电源方案.docx
- ADI电机运动控制解决方案驱动智能运动新时代.docx
- 用于1500V光伏逆变器的功率模块解决方案.docx
- 2017年深圳英语中考---阅读理解.pdf
- 2021年学校双减工作实施方案.pdf
文档评论(0)