以下是一个程序,输出您的Last,First Middle到First Middle初始的last,任何人都可以通过此程序帮助我. [英] The following is a program thats output your Last, First Middle to First middle initial last, any body can help me with this program, thanks.

查看:157
本文介绍了以下是一个程序,输出您的Last,First Middle到First Middle初始的last,任何人都可以通过此程序帮助我.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

主要方法
1.声明一个名为myString的字符串.
2.使用按引用调用将您的字符串传递给名为inputData()的方法; (提示:使用&)
3.使用按值调用,并将您的字符串传递给名为outputData()的方法; (提示:不使用&)
inputData方法(接收字符串)
1.使用cin>>获得输入到您在此方法中收到的字符串变量中. (我将以以下格式输入我的全名:Last,First Middle.
2.使用本周讲座中提到的字符串方法,让您的程序将字符串更改为:First Middle Initial Last.
3.我希望您将收到的字符串分成3个单独的变量:第一,最后,中间. (提示:使用find()查找,"和空格,并使用substr()提取片段)
4.使用字符串连接重新组合字符串,并用新值覆盖收到的字符串.
5.您必须使用以下每个字符串方法(至少一次):substr(),length(),find(),insert(),erase().
6.请注意,名称中缺少,".
outputData方法(接收字符串)
1.使用cout<<将新字符串输出到屏幕.
2.需要注释,但不需要伪代码或流程图.
3.所有输入/输出应使用标准C ++库字符串类完成.
4.包括:system("PAUSE");在您的输出以暂停屏幕后.

Main Method
1. Declare a string called myString.
2. Use Call-by-reference pass your string to a method called inputData(); (Hint: uses the &)
3. Use Call-by-value and pass your string to a method called outputData(); (Hint: does not use the &)
inputData Method (Receives string)
1. Get input using cin >> into the string variable you received into this method. (I will be entering my full name in the format of: Last, First Middle.
2. Using the string methods mentioned in this weeks lecture, have your program change the string to: First Middle Initial Last.
3. I would like you to break the string you received apart into 3 separate variables: first, last, middle. (Hint: use find() to find the "," and spaces and use substr() to extract the pieces)
4. Use string concatenation to reassemble the string and overwrite the string you received with the new value.
5. You must use each of the following string methods (at least once): substr(), length(), find(), insert(), erase().
6. Notice the "," is missing out of the name.
outputData Method (Receives string)
1. Output the new string to the screen using cout <<.
2. Comments are required, but pseudocode or flowchart are not.
3. All Input/Output should be done using the standard C++ library string class.
4. Include: system("PAUSE"); after your output to pause the screen.

推荐答案

我们不做您的作业:这是有原因的.在这里,您可以考虑自己被告知的内容,并尝试理解它.也可以在那里帮助您的导师识别您的弱点,并将更多的注意力放在补救措施上.

自己尝试,您可能会发现它比您想象的要容易.
We do not do your homework: it is set for a reason. It is there so that you think about what you have been told, and try to understand it. It is also there so that your tutor can identify areas where you are weak, and focus more attention on remedial action.

Try it yourself, you may find it is easier than you think.


这篇关于以下是一个程序,输出您的Last,First Middle到First Middle初始的last,任何人都可以通过此程序帮助我.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆