有关字符串和数组分配的问题 [英] Issues with an assignment on strings and arrays

查看:67
本文介绍了有关字符串和数组分配的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好

我正在使用Visual Studio 2015,并且是最近才开始的,我被分配了作业,似乎无法解决任何问题.我紧急帮助.作业如下,我完成了第1部分,但我听不懂第2部分和第3部分.

I am using Visual Studio 2015 and just began recently, I got slapped with an assignment and can't seem to figure anything out. I help urgently. The assignment is below, I got through part 1 but I can't understand part 2 and 3.

谢谢!


设计和编码

Design and Coding

第一部分:字符串解析(40%)

Part I: string parsing (40%)

2.加载表单时,初始化一个字符串,以包含您的名字和姓氏,您的学生编号,您喜欢的颜色,您喜欢的月份和您的出生年份(不 必须是事实).用逗号分隔每个名称.例如,

2. When the form loads, initialize a string to contain YOUR first and last name, YOUR student number, YOUR favorite color, YOUR favorite month, and YOUR year of birth (does not have to be the truth). Separate each with a comma expect the names. For example,

strParsing ="Chuck Norris,1234567,蓝色,1492年8月"

strParsing = "Chuck Norris, 1234567, blue, August, 1492"

在加载表单时,将上述字符串显示在文本框中,且该字符串居中对齐.请注意,该程序对于具有这种格式的任何字符串都应相同的工作, 并且在评估程序时将使用不同的字符串.

Display the above string in a textbox with the string aligned at center, when the form loads. Please note that the program should work the same for any string that has this format, and that different strings will be used when your program is being evaluated.

3.添加控件以允许用户执行下面列出的每个任务(每个控件一个任务):

3. Add controls to allow the user to do each of the tasks listed below (one task per control):

(1)根据您的年份显示年龄字符串中的出生日期和当前年份.使用内置函数查找当前年份.

(1) Display your age based on your year of birth as found in the string, and the current year. Find the current year using a built-in function.

(2)向后显示字符串.

(2) Display the string backwards.

(3)返回字/值的数量在字符串中.您的代码必须弄清楚这一点,显示"6"不正确.提示:使用逗号和空格 检查字/值的分隔,但不要重复计算.

(3) Return the number of words/values in the string. Your code must figure this out, displaying "6" is not correct. Hint: use commas and spaces to check separation of words/values, but don’t double count.

(4)计算字符串并显示它;即,对于上面的示例,数字是1、2、3、4、5、6、7和1、4、9、2. 这些总数为44.

(4) Calculate the total of the digits in the string and display it; i.e., for the example above, the digits are 1, 2, 3, 4, 5, 6, 7 and 1, 4, 9, 2. These total to 44.

(5)使用 一个标签以显示任务的结果;也就是说,新结果将覆盖标签中显示的先前结果.设置标签属性,如下所示: TextAlign à MiddleCenter BorderStyle à 固定3D AutoSize à False .

(5) Use one label to display the result of a task; i.e., the new result will overwrite the previous result shown in the label. Set the label properties as follows: TextAlign à MiddleCenter, BorderStyle à Fixed3D, and AutoSize à False.

注意:显示的所有数据必须来自原始字符串,且其中的原始字符该字符串必须保留;即,对于包含完整内容的任务 字符串,逗号仍必须在字符串中.

Note: all the data that are displayed must come from the original string, and the original characters in the string must be preserved; i.e., for tasks that include the complete string, the commas must still be in the string.

第二部分:字符串解密(20% )

 Part II: string decipher (20%)

4.继续进行该项目,并在加载表单时添加下面给出的字符串.

4. Continue on the project, and add the string given below when the form loads.

strDecipher ="AXCEWCLLPD ENOF.E";

strDecipher = "AXCEWCLLPD ENOF.E"

5.编写程序来解密字符串.解密算法是从字符串的第一个位置开始,然后向前移动4个位置并拾取字符 在该位置上,然后向后移动1个位置并在该位置上拾取角色.拾取的所有字符都按顺序存储在新字符串中.解密过程一直持续到到达字符串的末尾为止;然后全部 新字符串中的拾取字符将显示在标签中.

5. Write a program to decipher a string. The deciphering algorithm is that start from the very first position of a string, and move forward 4 positions and pick up the character at that position, then move backward 1 position and pick up the character at that position. All the characters that are picked up are sequentially stored in a new string. The deciphering process continues until the end of the string is reached; and then all the picked-up characters in the new string are displayed in a label.

6.加载表单时显示源字符串.并在按下解密字符串"按钮时显示解密的字符串.

6. Display the source string, when the form loads. And display the deciphered sting as well, when a button Decipher a String is pressed.

7.您可以将上面给出的字符串用作示例字符串;但是该程序对于任何字符串都应工作相同.请注意,您的程序将使用不同的字符串 正在评估中.

7. You can use the string given above as a sample string; but the program should work the same for any string. Please note that different strings will be used when your program is being evaluated.

第三部分:数组操作(40%)

Part III: array manipulations (40%)

8.继续进行该项目,并在加载表单时创建下面给出的数组.

8. Continue on the project, and create an array given below when the form loads.

arParts = {535,480,601,849,777,1150,762,323,688 ,974,1006,596}

arParts = {535, 480, 601, 849, 777, 1150, 762, 323, 688, 974, 1006, 596}

9.此阵列由一年中的每个月(从一月到十二月)生产的零件组成.

9. This array consists of a collection of parts produced in each month of a year, from Jan to Dec.

10.当按下列出原始数据"按钮时,编写一个程序以在列表框中列出阵列数据和相应月份,如右图所示.

10. Write a program to list the array data and the corresponding months in a list box, as shown on the right, when a button List Original Data is pressed.

11.按升序对原始数据进行排序,然后在按排序升序"按钮时,将结果列在位于第一个列表框旁边的第二个列表框中.

11. Sort the original data by ascending, and list the results in a second list box that is placed beside the first list box, when a button Sort Ascending is pressed.

请注意,第二个列表框中仍然有两列,其中一列为升序排列零件,另一个用于排序的对应月份.

Please note that there are still two columns in the second list box, one column for the ascendingly sorted parts, and the other for the sorted corresponding months.

12.按降序对原始数据进行排序,然后在按下排序降序按钮时将结果列出在第二个列表框旁边的第三个列表框中


推荐答案

我建议您与任何打耳光"的人联系.为您分配了您不了解其领域的作业,以便该人可以向您解释您对这些领域尚不清楚且需要澄清的问题.

I suggest you contact whoever "slapped" you with an assignment which you don't understand areas of so that person can explain areas to you that you have questions about that seem unclear and need clarification.

尽管第二和第三部分写得很好,如果课程材料包含第二和第三部分所述的用法,则提供完成任务所需的所有信息,我猜想否则,任何人都可能被拍打".带着 他们没有知识并且没有被教导必要的信息的分配,因此他们可以完成对他们的拍打"帮助.与?

Although part II and III seem well written providing all information necessary to complete the tasks if the course material contains usages described in part II and III which I would guess it does otherwise how could anybody be "slapped" with an assignment where they have no knowledge and haven't been taught necessary information so they can complete an assisgnment they were "slapped" with?

对于第二部分,您应该编写一种算法,该算法对于从索引0开始的任何字符串,向前移动四个位置,然后向后移动一个位置,然后向前移动四个位置,然后向后移动一个位置,然后一直持续到字符串是 命中.

With regard to part II you are supposed to write an algorithm that for any string that starts at index 0, moves forward four positions and then back one position then forward four positions then back one position and on and on till the end of a string is hit.

此字符串 strDecipher ="AXCEWCLLPD ENOF.E".将会有一个17的计数,从索引0开始,到索引16结束.因此,您的算法应从0到strDecipher.Count-1进行处理,这将是17个数字,从0到16. 0,向前移动4,然后向后移动1,然后继续)4、3、7、6、10、9、13、12和16是索引,以便您需要从strDecipher中获取字符在新字符串中显示在标签中.如果你不知道怎么写 算法,执行此功能是一回事,如果您不知道如何遍历字符串以在特定索引位置从字符串中获取字符以提供给其他字符串,则是另一回事.

Well this string strDecipher = "AXCEWCLLPD ENOF.E" would have a count of 17 and start at index 0 and end at index 16. So your algorithm should process from 0 to strDecipher.Count - 1 which would be 17 numbers of 0 to 16. And out of those numbers I guess (start at 0 and move forward 4 then back 1 and continue) 4, 3, 7, 6, 10, 9, 13, 12 and 16 would be the indexes in order that you need to get a character from in strDecipher to place in a new string for display in a label. If you don't know how to write an algorithm to perform this functionality that is one thing, if you have no idea how to move through a string to get characters from it at specific index locations to provide to another string that is something else.

我建议您编写一个提供输入字符串的函数,然后返回一个输出字符串,并且算法的所有代码都在该函数内.

I would suggest you write a Function that you provide an input string to and it returns an output string and all code for the algorithm is within the Function.


这篇关于有关字符串和数组分配的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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