- 1、有哪些信誉好的足球投注网站(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。。
- 2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 3、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
- 4、该文档为VIP文档,如果想要下载,成为VIP会员后,下载免费。
- 5、成为VIP后,下载本文档将扣除1次下载权益。下载后,不支持退款、换文档。如有疑问请联系我们。
- 6、成为VIP后,您将拥有八大权益,权益包括:VIP文档下载权益、阅读免打扰、文档格式转换、高级专利检索、专属身份标志、高级客服、多端互通、版权登记。
- 7、VIP文档为合作方或网友上传,每下载1次, 网站将根据用户上传文档的质量评分、类型等,对文档贡献者给予高额补贴、流量扶持。如果你也想贡献VIP文档。上传文档
查看更多
C++Primer习题(第三章附答案) 练习3.1 略 练习 3. 2 编写⼀段程序从标准输⼊中⼀次读⼊⼀整⾏,然后修改程序使其⼀次读⼊⼀个词。 #include iostream #includestring using namespace std ; 使⽤ ⼀次读⼊⼀整⾏,回车结束 // getline int main() { string line ; cout please enter your line ,even space endl; 循环读取, 结束 while (getline(cin, line)) // Ctrl+c cout line endl; return 0; } #include iostream #includestring using namespace std ; 使⽤ ⼀次读⼊⼀单词,空⽩结束 // cin int main() { string word ; cout please enter your word ,not space endl; 循环读取, 结束 while (cinword) // Ctrl+c cout word endl; return 0; } 练习3.3 请说明string类的输⼊运算符和getline函数是如何分别处理空⽩字符的 #includeiostream #includestring using namespace std ; int main() { string word, line ; cout please select the way to read the string endl; cout 1 means read string by word endl; cout 2 means read string by line endl; char ch ; cin ch ; if (ch == 1) { cout please enter string : welcome to c++ family endl; cin word ; cout system read the string is : word endl; } else if (ch == 2) { cout please enter string : welcome to c++ family endl; getline(cin, line); cout system read the string is : line endl; } else { cout input error,please try again endl; } return 0; } 练习3.4 编写⼀段程序读⼊两个字符窜,⽐较其是否相等并输出结果。结果不相等,输出较⼤的那个字符串。改写上述程序,⽐较输⼊的两 个字符串是否等长,如果不等长,输出长度较⼤的那个字符串。 #includeiostream #includestring using namespace std ; int main() { string word1, word2 ; cout please enter two strings endl; cin word1 word2 ; if (word1 == word2) { cout word1 endl; } else if (word1word2) { cout word1 endl; } else { cout word2 endl; } return 0; } #includeiostream #includestring using namespace std ; int main() { string word1, word2 ; cout please ent
您可能关注的文档
- 2022-2023学年江西省赣州市赣州中学高考化学二模试卷含解析 .pdf
- 2023学年高二上学期12月阶段考试文科地理试题 .pdf
- 2023年环境影响评价工程师之环评法律法规模拟题库及附答案 .pdf
- 2023年一级建造师-民航机场工程管理与实务考试备考题库附带答案1.pdf
- 2023年面试题及答案 .pdf
- 2021年高考仿真试题(三)(理综化学) .pdf
- 2022年北京市丰台区中考语文模拟试题(含答案) .pdf
- 2022年江苏省徐州市中考物理考前模拟试题及答案解析 .pdf
- 2023届广西柳州市高三第二次模拟考试英语试题 .pdf
- 《战略管理》模拟题 .pdf
- 【中考冲刺】2023年广西钦州市中考模拟生物试卷(附答案) .pdf
- 2019年佛山市中考语文模拟试题与答案 .pdf
- 2022年湖南省常德市汉寿县中考一模生物试题(word版含答案) .pdf
- 湖北省黄冈八模系列2022届高三模拟测试(五)理综模拟试题Word版含答案精品.pdf
- 露采。思考题及答案 .pdf
- 2023年安全员之C证(专职安全员)题库附答案(基础题) .pdf
- 2023年环境影响评价工程师之环评技术导则与标准能力提升试卷A卷附答案精品.pdf
- 2023年电大本科土木工程工程地质试题及答案 .pdf
- 年一级建造师之一建建设工程项目管理基础试题库和答案要点 .pdf
- 2022-2023学年四川省凉山州宁南中学高二下学期第一次月考地理试题.pdf
有哪些信誉好的足球投注网站
文档评论(0)