本文介绍了如何编写这个初学者C ++问题?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 每个邮寄物品的邮资取决于物品的基本费用:如果基本费用低于100,则收取低额费用;否则,收取高额费用。物品的总成本是其基本成本和邮资的总和。该程序输入2个项目的数量和基本成本作为整数,并输出它们的总成本之和,再次作为整数。 什么我试过了: 我试过,如果,别的东西,但我不知道怎么去解决这个问题。我也试过投入一笔费用和数量。 我添加了这个但我得到了语法错误 如果 和 否则。所以这个就是我所拥有的: if (sum< 100) cout<< 低<< endl; int 费用=总和+总和 else cout<< 高<< ENDL; int 成本=总和+总和> = 100 ; cout<< 费用<<<<< endl; 其他 做我改进了这个? 此外,我希望输出显示完整的金额加上低或高邮资价格。 } 解决方案 教科书中的练习是与以前的课程相关,所以,可能重读课程可以提供帮助。 如果你遇到困难,你可以找到教程和视频(在YouTube上)。 以下是语言作者对C和C ++参考书的链接。注意,C是C ++的祖先,所以知道C对C ++总是有用。 C编程语言 - 维基百科,免费的百科全书 [ ^ ] https://hassanolity.files.wordpress.com/2013/11/the_c_programming_language_2。 pdf [ ^ ] http://www.ime.usp。 br / ~pf / Kernighan-Ritchie / C-Programming-Ebook.pdf [ ^ ] C ++编程语言 [ ^ ] [更新] 阅读此内容并注意{}用法: 什么是花括号? [ ^ ] The postage for each mailed item depends on the base cost of the item: if the base cost is less than 100, then an amount lowpostage is charged; otherwise, highpostage is charged. The total cost of an item is the sum of its base cost and its postage. This program inputs the quantity and base cost of 2 items as integers, and outputs the sum of the total costs for them, again as an integer.What I have tried:I have tried if, else stuff but im not sure how to go about solving this. I have also tried putting in a cost and the quantity.I added this but I get syntax error in if and else. So this is what I have:if (sum<100)cout<<"Low"<<endl;int Charge=sum+sum<100;elsecout<<"High"<<endl;int Cost=sum+sum>=100;cout<<"Cost "<<Cost<<endl;There is a syntax error in else how do I improve this ?Also I would like the output to show the complete sum plus low or high postage price.} 解决方案 Exercises in textbooks are related to previous lessons, so, may be rereading the lesson can help.If you are stuck, you can find tutorials and videos (on YouTube).Here is links to references books on C and C++ by the authors of the languages. Note than C is the ancestor of C++, so knowing C is always useful with C++.The C Programming Language - Wikipedia, the free encyclopedia[^]https://hassanolity.files.wordpress.com/2013/11/the_c_programming_language_2.pdf[^]http://www.ime.usp.br/~pf/Kernighan-Ritchie/C-Programming-Ebook.pdf[^]C++ Programing Language[^][Update]read this and pay attention to {} usage:What is curly bracket?[^] 这篇关于如何编写这个初学者C ++问题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!