{"action":"created","issue":{"url":"https://api.github.com/repos/wujr5/c-and-cpp-language-learning/issues/18","labels_url":"https://api.github.com/repos/wujr5/c-and-cpp-language-learning/issues/18/labels{/name}","comments_url":"https://api.github.com/repos/wujr5/c-and-cpp-language-learning/issues/18/comments","events_url":"https://api.github.com/repos/wujr5/c-and-cpp-language-learning/issues/18/events","html_url":"https://github.com/wujr5/c-and-cpp-language-learning/issues/18","id":115364871,"number":18,"title":"计科：week6 第四次实验 程序流程图和伪代码","user":{"login":"wujr5","id":7693440,"avatar_url":"https://avatars.githubusercontent.com/u/7693440?v=3","gravatar_id":"","url":"https://api.github.com/users/wujr5","html_url":"https://github.com/wujr5","followers_url":"https://api.github.com/users/wujr5/followers","following_url":"https://api.github.com/users/wujr5/following{/other_user}","gists_url":"https://api.github.com/users/wujr5/gists{/gist_id}","starred_url":"https://api.github.com/users/wujr5/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wujr5/subscriptions","organizations_url":"https://api.github.com/users/wujr5/orgs","repos_url":"https://api.github.com/users/wujr5/repos","events_url":"https://api.github.com/users/wujr5/events{/privacy}","received_events_url":"https://api.github.com/users/wujr5/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/wujr5/c-and-cpp-language-learning/labels/%E8%AE%A1%E7%A7%91%E7%8F%AD","name":"计科班","color":"207de5"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":25,"created_at":"2015-11-05T20:14:30Z","updated_at":"2015-11-11T11:01:06Z","closed_at":null,"body":"# week6 第四次实验 程序流程图和伪代码\r\n\r\n> 实验目的：当大家学习了程序的控制结构之后，代码就变得复杂起来。在这时，我们解决问题就需要有很严密的逻辑思维。程序流程图和伪代码就是帮助我们去描述我们解决问题的方法（也称为算法）的工具。本次实验在于让大家学习如何使用这些工具，这对大家以后的编程有很大的帮助。\r\n\r\n## 1 Flowchart (程序流程图)\r\n\r\nA flowchart is a type of diagram that represents an algorithm, workflow or process, showing the steps as boxes of various kinds, and their order by connecting them with arrows. This diagrammatic representation illustrates a solution model to a given problem. Flowcharts are used in analyzing, designing, documenting or managing a process or program in various fields.\r\n\r\n> From wikipedia\r\n\r\nDetailed Description: [flowchat](https://en.wikipedia.org/wiki/Flowchart)\r\n\r\nThere is an example:\r\n\r\n![ab](https://cloud.githubusercontent.com/assets/8371330/10778410/11bec644-7d61-11e5-830d-548028f14db4.jpg)\r\n\r\nAnd this is the flowchart: \r\n\r\n![sample](https://cloud.githubusercontent.com/assets/8371330/10778656/52724c18-7d63-11e5-8b49-55f204fedefe.png)\r\n\r\n## 2 Pseudocode (伪代码)\r\n\r\nPseudocode is an informal high-level description of the operating principle of a computer program or other algorithm.\r\n\r\n> From wikipedia\r\n\r\nThere is an example:\r\n\r\n![1](https://cloud.githubusercontent.com/assets/8371330/10791003/6156338a-7dc1-11e5-8b7e-364f1a559db5.png)\r\n\r\nWe can describe this question by this way rather than write a C++ program immediately:\r\n\r\n```cpp\r\nmain {\r\n\tinput two integers height and n\r\n\tinitialize answer = 0\r\n\t\r\n\tloop for n times {\r\n    \tinput tree_height\r\n    \tif height >= tree_height:\r\n       \t\tanswer = answer + 1\r\n  \t}\r\n  \t\r\n\tprint answer\r\n}\r\n```\r\n\r\nPseudocode is used to express your thought, you do not need to care about the grammar.\r\n\r\n## 3 Pre Assignment\r\n\r\nLearn about Flowchart and Pseudocode.\r\n\r\n## 4 Assignment (100pts)\r\n\r\n### 4.1 Assignment 0 (20pts)\r\n\r\nChoose one question from soj.me in week6 in our course and then write the Pseudocode.\r\n\r\n### 4.2 Assignment 1 (35pts) \r\n\r\nTranslate the following flowchart into Pseudocode\r\n\r\n#### Description\r\n\r\nSeveral surveys indicate that the taller you are, the higher you can climb the corporate ladder. At TALL Enterprises Inc. this \"de facto standard\" has been properly formalized: your boss is always at least as tall as you are. Furthermore, you can safely assume that your boss earns a bit more than you do. In fact, you can be absolutely sure that your immediate boss is the person who earns the least among all the employees that earn more than you and are at least as tall as you are. Furthermore, if you are the immediate boss of someone, that person is your subordinate, and all his subordinates are your subordinates as well. If you are nobody's boss, then you have no subordinates. As simple as these rules are, many people working for TALL are unsure of to whom they should be turning in their weekly progress report and how many subordinates they have. Write a program that will help in determining for any employee who the immediate boss of that employee is and how many subordinates they have. Quality Assurance at TALL have devised a series of tests to ensure that your program is correct. These test are described below.\r\n\r\nMay be you can not write out the problem, the only work you will do is write out this program from the following flowchart(Since there are many methods to sort, so you can use one of them, the flowchart does not display in the flow chat, instead a dashed line).\r\n\r\n#### Flowchart\r\n\r\n![flowchart 2](https://cloud.githubusercontent.com/assets/7850960/10865105/10cbe662-803c-11e5-95d3-3adc2394dcdd.png)\r\n\r\n#### Simple input and output\r\n\r\n##### Input\r\n\r\n2  \r\n3  \r\n123456 14323 1700000   \r\n123458 41412 1900000   \r\n123457 15221 1800000   \r\n123458   \r\n4  \r\n200002 12234 1832001   \r\n200003 15002 1745201   \r\n200004 18745 1883410   \r\n200001 24834 1921313   \r\n200002   \r\n\r\n##### Output\r\n\r\n(0,2)   \r\n(200004,0)   \r\n\r\n### 4.3 Assignment 2 (35pts) \r\n\r\nDraw a flowchart from the following C++ language program which constructs a **bubble sort algorithm**.\r\n\r\n```cpp\r\n#include <iostream>\r\nusing namespace std;\r\n\r\nvoid print(int* pData, int count) {\r\n\tfor (int i = 0; i< count; i++) {\r\n\t\tcout << pData[i] << \" \";\r\n\t}\r\n\tcout << endl;\r\n}\r\n\r\nvoid BubbleSort(int* pData, int count) {\r\n    int temp;\r\n    for (int i = 1; i < count; i++) {\r\n    \tbool flag = true;\r\n    \t\r\n        for (int j = 0; j < count - i; j++) {\r\n            if (pData[j] > pData[j+1]) {\r\n            \ttemp = pData[j+1];\r\n                pData[j+1] = pData[j];\r\n                pData[j] = temp;\r\n                flag = false;\r\n            }\r\n        }\r\n        \r\n        if (flag) break;\r\n        \r\n        cout << \"The \"<< i <<\" round:\" << endl;\r\n        print(pData, count);\r\n        cout << \"----------------------------\" << endl;\r\n        \r\n    }\r\n}\r\n\r\nint main() {\r\n\tint n;\r\n\tint data[100];\r\n\t\r\n    cout << \"How many numbers you want to input ? (less than 100)\" << endl;\r\n\tcin >> n;\r\n\tcout << \"Please input \" << n << \"numbers, separating with space: \" << endl;\r\n\t\r\n\tfor (int i = 0; i < n; i++) {\r\n\t\tcin >> data[i];\r\n\t}\r\n\t\r\n    BubbleSort(data, n);\r\n    \r\n    cout << \"The sort result:\" << endl;\r\n    \r\n    print(data, n);\r\n    \r\n    return 0;\r\n}\r\n```\r\n\r\n## 5 Extended Assignment (10pts)\r\n\r\nDraw a flowchart and write Pseudocode as well as a C++ language program for the following description.\r\n\r\n![extend](https://cloud.githubusercontent.com/assets/8371330/10779095/44aeb464-7d67-11e5-8219-e1c28d8b8113.png)\r\n\r\n## 6 Discussion，Cooperation and Summary (15pts)\r\n\r\nIn this part, you will have some options, if you do more options, you will learn more and get more marks.\r\n\r\n**You should note this part in your report**\r\n\r\n### option 1: Github Discussion\r\n\r\nComment at this issue and decribe a problem that you meet and how you solve detailedly.\r\n\r\n**Notice that** \r\n\r\n1. you should not copy and paste your personal report simply.\r\n2. you should not write a very simple one and your comment will be deleted if you do that.\r\n3. you should not post meaningless questions. \r\n\r\n### option 2: Simple Presentation\r\n\r\nHave a simple presentation in the lab class on Monday (4 persons limited). And after the presentation, everyone is encouraged to ask questions and you can get bonus by asking good questions.\r\n\r\n**Notice that**\r\n\r\n1. The presentation is no more than 5 minutes and there will be 5 extra minutes for discussion.\r\n2. You should prepare much for it.\r\n3. First come, first get the opportunity.\r\n\r\n### option 3: Helping others\r\n\r\nYou can help others to slove any problems the will meet. Detailedly decribe the quesion, the solution and your personal experience as well.\r\n\r\n**Notice that**\r\n\r\n1. it's no need to consult with others that I help you, you help you to get marks. You can simply send email to me and I will give you the marks.\r\n\r\n### option 4: Personal Summary\r\n\r\nWrite personal summary for yourself.\r\nList at least 10 problems that you have met in your learning in c language and decribe the solution as well.\r\n\r\n**Notice that**\r\n1. you should not have ten very simple problems, you must let me know your learning method and also the method to solve problems.\r\n\r\n## 7 Report Template\r\n\r\nThere will be no Report Template this time which means it's all depends on yourself.\r\n\r\n**Notice that**\r\n\r\n1. the report is the most important document for your project, you should pay more attention to it.\r\n2. you are supposed to write a report that is friendly to your 'users', which means that you need to consider about the typesetting, the logical structure of the content.\r\n3. There should contain one item, self grading that you should give a score to evaluate your job as well as a reason.\r\n\r\nFor example: [sinew](http://yejq.sinaapp.com/blog/sinew)\r\n\r\n## 8 Flowchart Tool: Process On\r\n\r\nProcess on is a good tool for drawing flowchart.\r\n[link](https://www.processon.com/)\r\n\r\n## 9 Submit List\r\n\r\n![2](https://cloud.githubusercontent.com/assets/8371330/10793052/37c34ee6-7dca-11e5-8620-bd1e6c113087.png)\r\n\r\n**Notice that:**\r\n13331314 means your student id.\r\nthe first assignment need to name your file with your chosen problem id.\r\n\r\n## 10 Deadline\r\n\r\n**23:59 on Nov 12th, 2015**\r\n\r\n## 11 Notification\r\n\r\n1. Submit after deadline will cause a 30% penalty.\r\n2. If your file structure of filename is wrong, you will probably get 0 in that part.\r\n3. Any questions, you can ask us and email is better.\r\n4. Full mark will be 100, but you may get more than 100 within this project.\r\n5. You can use any tool include word, process on to draw a flowchart. You can use any form to write your Pseudocode but should be of high readability. If TA can not understand your Pseudocode clearly, you will get low points.(you can use Chinese to write Pseudocode if you like).\r\n"},"comment":{"url":"https://api.github.com/repos/wujr5/c-and-cpp-language-learning/issues/comments/155736620","html_url":"https://github.com/wujr5/c-and-cpp-language-learning/issues/18#issuecomment-155736620","issue_url":"https://api.github.com/repos/wujr5/c-and-cpp-language-learning/issues/18","id":155736620,"user":{"login":"abbcABBC","id":15702531,"avatar_url":"https://avatars.githubusercontent.com/u/15702531?v=3","gravatar_id":"","url":"https://api.github.com/users/abbcABBC","html_url":"https://github.com/abbcABBC","followers_url":"https://api.github.com/users/abbcABBC/followers","following_url":"https://api.github.com/users/abbcABBC/following{/other_user}","gists_url":"https://api.github.com/users/abbcABBC/gists{/gist_id}","starred_url":"https://api.github.com/users/abbcABBC/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/abbcABBC/subscriptions","organizations_url":"https://api.github.com/users/abbcABBC/orgs","repos_url":"https://api.github.com/users/abbcABBC/repos","events_url":"https://api.github.com/users/abbcABBC/events{/privacy}","received_events_url":"https://api.github.com/users/abbcABBC/received_events","type":"User","site_admin":false},"created_at":"2015-11-11T11:01:06Z","updated_at":"2015-11-11T11:01:06Z","body":"@wujr5 我在代码里用了goto，可以么？"}}