代写CMPSC-121作业、代做C/C++编程作业、代写Programming Techniques作业、代做C/C++语言留学生作业
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了代写CMPSC-121作业、代做C/C++编程作业、代写Programming Techniques作业、代做C/C++语言留学生作业,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含4253字,纯文字阅读大概需要7分钟。
内容图文
![代写CMPSC-121作业、代做C/C++编程作业、代写Programming Techniques作业、代做C/C++语言留学生作业](/upload/InfoBanner/zyjiaocheng/850/f54750a32e0140568d296856c5a489cd.jpg)
代写CMPSC-121作业、代做C/C++编程作业、代写Programming Techniques作业、代做C/C++语言留学生作业
CMPSC-121: Intro to Programming Techniques
Homework 9 - 20 points (Fall 2018)
Due Sunday, October 21 at 11:59pm
Objectives
After this homework assignment, students should be able to:
Use multi-dimensional arrays
Use random number generation in programs
Background
A game uses a 10*10 grid to represent the terrain of the surface of the moon on which a lunar lander may land.
Unfortunately, not all parts of the surface are safe to land. Unsafe locations are indicated by 0s and safe
locations are left blank.
| 0 1 2 3 4 5 6 7 8 9
--+--------------------
0 | 0 0 0
1 | 0 0 0 0 0 0
2 | 0 0 0 0 0
3 | 0 0
4 | 0 0 0 0 0
5 | 0 0 0 0
6 | 0 0 0
7 | 0 0 0 0 0 0
8 | 0 0 0 0 0
9 | 0 0 0 0 0 0
Instructions
Write a program named lunarlander.cpp that:
Declares a 2D integer array of size 10*10 that represents the terrain
Uses random number generation to populate safe and unsafe locations of the terrain
o Each location in the grid has 50% probability to be safe and 50% to be unsafe
o Safe locations are represented by the number 1
o Unsafe locations are represented by the number 0
Displays a well-formatted table that visualizes the terrain
Prompts the user to enter the (x, y) coordinates of the desired landing location
Implements and calls a function that attempts to land the lunar lander
o bool land(int location);
If the location is safe, whomever calls land should change its value to 3 to indicate the
lunar lander has landed successfully
Parameters:
int location: a variable to the element in the 2D array that was selected by
the user.
Return value:
true: if the location is safe
false: if the location is unsafe
If the location is unsafe, displays a message to the user and prompts for another (x, y) coordinates to
attempt a landing, until a successful one is entered.
You may NOT use any global variables in this program.
Optional Bonus (+4 points)
Write a program named lunarrover.cpp that extends the functionality of lunarlander.cpp by:
Prompting the user to enter one of four directions in which to move: left, right, up, down
o Validate the user input for one of the four possibilities
Making sure that the proposed move keeps the rover inside the grid
o For example, do not accept an attempted move to the left from (0, 5)
Implementing a function that simulates the movement of the lunar rover:
o bool move(int *old_location, int *new_location);
? If the new location is safe, change its value to 3 and the old location to 1 to indicate a
successful move, then return true
If the new location is unsafe, then return false
In a loop, prompt the user to move the rover until it attempts an unsafe move
You may NOT use any global variables in this program.
Sample Output
Task 1 Sample Output
| 0 1 2 3 4 5 6 7 8 9
--+--------------------
0 | 0 0 0 0 0
1 | 0 0 0 0 0 0 0
2 | 0 0 0 0 0 0
3 | 0 0 0 0 0 0 0 0
4 | 0 0 0 0
5 | 0 0 0 0 0
6 | 0 0 0 0 0 0
7 | 0 0 0 0 0 0
8 | 0 0 0 0
9 | 0 0 0 0
Enter (x, y) coordinates: 3 3
CRASH! Try again!
Enter (x, y) coordinates: 4 4
| 0 1 2 3 4 5 6 7 8 9
--+--------------------
0 | 0 0 0 0 0
1 | 0 0 0 0 0 0 0
2 | 0 0 0 0 0 0
3 | 0 0 0 0 0 0 0 0
4 | 0 3 0 0 0
5 | 0 0 0 0 0
6 | 0 0 0 0 0 0
7 | 0 0 0 0 0 0
8 | 0 0 0 0
9 | 0 0 0 0
SUCCESSFUL LANDING!
Optional Bonus Sample Output
| 0 1 2 3 4 5 6 7 8 9
--+--------------------
0 | 0 0 0 0
1 | 0 0 0 0 0 0
2 | 0 0 0 0 0
3 | 0 0 0 0 0 0
4 | 0 0 0 0 0 0
5 | 0 0 0 0
6 | 0 0 0 0 0 0
7 | 0 0 0 0 0
8 | 0 0 0 0 0
9 | 0 0
Enter (x, y) coordinates: 1 1
CRASH! Try again!
Enter (x, y) coordinates: 4 5
| 0 1 2 3 4 5 6 7 8 9
--+--------------------
0 | 0 0 0 0
1 | 0 0 0 0 0 0
2 | 0 0 0 0 0
3 | 0 0 0 0 0 0
4 | 0 0 0 3 0 0 0
5 | 0 0 0 0
6 | 0 0 0 0 0 0
7 | 0 0 0 0 0
8 | 0 0 0 0 0
9 | 0 0
SUCCESSFUL LANDING!
Enter a move (L, R, U, or D): N
Invalid move! Try again!
Enter a move (L, R, U, or D): D
| 0 1 2 3 4 5 6 7 8 9
--+--------------------
0 | 0 0 0 0
1 | 0 0 0 0 0 0
2 | 0 0 0 0 0
3 | 0 0 0 0 0 0
4 | 0 0 0 0 0 0
5 | 0 0 3 0 0
6 | 0 0 0 0 0 0
7 | 0 0 0 0 0
8 | 0 0 0 0 0
9 | 0 0
Optional Bonus Sample Output (continued)
Submission
Submit the following file(s) to Canvas before the deadline:
1. lunarlander.cpp
2. (optional bonus) lunarrover.cpp
http://www.daixie0.com/contents/13/1897.html
因为专业,所以值得信赖。如有需要,请加QQ:99515681 或邮箱:99515681@qq.com
微信:codinghelp
内容总结
以上是互联网集市为您收集整理的代写CMPSC-121作业、代做C/C++编程作业、代写Programming Techniques作业、代做C/C++语言留学生作业全部内容,希望文章能够帮你解决代写CMPSC-121作业、代做C/C++编程作业、代写Programming Techniques作业、代做C/C++语言留学生作业所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。