99爱在线视频这里只有精品_窝窝午夜看片成人精品_日韩精品久久久毛片一区二区_亚洲一区二区久久

合肥生活安徽新聞合肥交通合肥房產(chǎn)生活服務(wù)合肥教育合肥招聘合肥旅游文化藝術(shù)合肥美食合肥地圖合肥社保合肥醫(yī)院企業(yè)服務(wù)合肥法律

CSCI1120代寫、代做C++設(shè)計(jì)程序
CSCI1120代寫、代做C++設(shè)計(jì)程序

時(shí)間:2024-10-02  來(lái)源:合肥網(wǎng)hfw.cc  作者:hfw.cc 我要糾錯(cuò)



CSCI1120 Introduction to Computing Using C++, Fall 2024/25
Department of Computer Science and Engineering, The Chinese University of Hong Kong
Assignment 2: Gumball Machines
Due: 23:59, Thu 3 Oct 2024 File name: gumball.cpp Full marks: 100
Introduction
The objective of this assignment is to let you practice control flow structures in C++. It also involves the use of variables, operators, expressions, and standard input/output to reinforce your learning in the course thus far. You are to write a program to print an ASCII character pattern resembling the drawing of a gumball vending machine, such as Figure 1 below.
     container
_____ /____\ // \\ // \\ // OOOOO\\ //OOOOOOO\\ \\OOOOOOO// \\OOOOOO// \\OOOOO// \\____// \_____/ |_|
| |_| |
𝑛 = side length of the hexagon gum
gum flap (chute door)
𝑛 = side length of the square
     stand || || |_ _ _ _ _|
Figure 1: A sample character pattern resembling a gumball machine This gumball machine character pattern is composed of two parts:
1. Container: A hexagonal shape in double dashed lines is used to represent the container holding the gumballs. Each gumball is denoted by a capital letter 'O'.
2. Stand: A square shape below the hexagon is used to represent the stand supporting the gumball container. A small square of unit length (always at the center of the 2nd line) inside this stand shape is used to represent the chute door, i.e., the opening where gumballs come out.
The whole pattern is formed from the set of characters in Table 1 below. Table 1: Characters for printing the ASCII art drawing
  Character
Name of the Character
  _ Underscore
| Pipe (Vertical bar)
\ Backslash
/ Forward slash
O Letter O (denoting a gum)
Space Copyright © 2024 CSE, CUHK
Page 1 of 8
            
CSCI1120 Introduction to Computing Using C++, Fall 2024/25
Department of Computer Science and Engineering, The Chinese University of Hong Kong
Instead of hardcoding, you are required to use loops and conditionals to print the drawing whose size can be scaled up or down according to the user input (See Table 2 for examples).
User Input
There are two user inputs required at the program start.
1. Side length (𝑛): it is the side length of the hexagon (or the square). This input controls the number of underscores that form the outer edge of the hexagon.
2. Stock of gumballs (w**4;w**5;w**0;𝑐𝑘): the initial number of gumballs to load into the vending machine.
Due to the double dashed line design of the hexagon and the spaces involved, the maximum number of gumballs that can be put into the container, i.e., its capacity (𝑐), is limited and determined by the following formula (deduced from the sum formula of an arithmetic series):
𝑐 = 3𝑛! − 8𝑛 + 5 ... (1)
Input validation
1. If the side length (𝑛) is smaller than 3, there is not enough room to print the chute door. When 𝑛 is getting too big, the output may overrun your terminal width and look distorted due to line wrapping. So, let us assume its valid range is between 3 and 29. (Note: in case you still see line wrapping issues in this range, you may resize your terminal via its settings.)
2. The initial number gumballs (w**4;w**5;w**0;𝑐𝑘) to load into the machine must lie between ⌊𝑐/2⌋ (floor of the division) and 𝑐, inclusive.
If the user input falls outside the valid range, the program will terminate immediately with an error message. See the Sample Runs section.
Size Scaling
Table 2 shows some examples to explain how the container shape and its capacity (𝑐) scale with the side length (𝑛) input.
Note that for making the width and height of the hexagon (or square) look similar in the console, we put a single space between every two underscores or two letter O’s in a horizontal line. For better visualization of the spaces required to produce the output, we used the symbol ␣ to denote a space character.
Machine Operations
Besides printing the gumball machine, the program will also prompt the user to enter a quantity of gumballs to buy. When the user enters a valid value (between 1 and w**4;w**5;w**0;𝑐𝑘), the quantity will be deducted from the stock and there will be fewer O’s shown in the next printout of the gumball machine. The program keeps repeating these operations until running out of stock.
 Copyright © 2024 CSE, CUHK Page 2 of 8

CSCI1120 Introduction to Computing Using C++, Fall 2024/25
Department of Computer Science and Engineering, The Chinese University of Hong Kong
Table 2: Sample output versus side length (𝑛) 𝒏3456
𝒄8 21 4**5
         ␣␣␣␣_␣_␣_ ␣␣/␣␣_␣_␣␣\ ␣/␣/␣O␣O␣\␣\ /␣/␣O␣O␣O␣\␣\ \␣\␣O␣O␣O␣/␣/ ␣\␣\␣_␣_␣/␣/ ␣␣\␣_␣_␣_␣/ ␣␣␣|␣␣_␣␣| ␣␣␣|␣|_|␣| ␣␣␣|_␣_␣_|
    ␣␣␣␣␣_␣_␣_␣_ ␣␣␣/␣␣_␣_␣_␣␣\ ␣␣/␣/␣O␣O␣O␣\␣\ ␣/␣/␣O␣O␣O␣O␣\␣\ /␣/␣O␣O␣O␣O␣O␣\␣\ \␣\␣O␣O␣O␣O␣O␣/␣/ ␣\␣\␣O␣O␣O␣O␣/␣/ ␣␣\␣\␣_␣_␣_␣/␣/ ␣␣␣\␣_␣_␣_␣_␣/ ␣␣␣␣|␣␣␣_␣␣␣| ␣␣␣␣|␣␣|_|␣␣| ␣␣␣␣|␣␣␣␣␣␣␣| ␣␣␣␣|_␣_␣_␣_|
   ␣␣␣␣␣␣_␣_␣_␣_␣_ ␣␣␣␣/␣␣_␣_␣_␣_␣␣\ ␣␣␣/␣/␣O␣O␣O␣O␣\␣\ ␣␣/␣/␣O␣O␣O␣O␣O␣\␣\ ␣/␣/␣O␣O␣O␣O␣O␣O␣\␣\ /␣/␣O␣O␣O␣O␣O␣O␣O␣\␣\ \␣\␣O␣O␣O␣O␣O␣O␣O␣/␣/ ␣\␣\␣O␣O␣O␣O␣O␣O␣/␣/ ␣␣\␣\␣O␣O␣O␣O␣O␣/␣/ ␣␣␣\␣\␣_␣_␣_␣_␣/␣/ ␣␣␣␣\␣_␣_␣_␣_␣_␣/ ␣␣␣␣␣|␣␣␣␣_␣␣␣␣| ␣␣␣␣␣|␣␣␣|_|␣␣␣| ␣␣␣␣␣|␣␣␣␣␣␣␣␣␣| ␣␣␣␣␣|␣␣␣␣␣␣␣␣␣| ␣␣␣␣␣|_␣_␣_␣_␣_|
   ␣␣␣␣␣␣␣_␣_␣_␣_␣_␣_ ␣␣␣␣␣/␣␣_␣_␣_␣_␣_␣␣\ ␣␣␣␣/␣/␣O␣O␣O␣O␣O␣\␣\ ␣␣␣/␣/␣O␣O␣O␣O␣O␣O␣\␣\ ␣␣/␣/␣O␣O␣O␣O␣O␣O␣O␣\␣\ ␣/␣/␣O␣O␣O␣O␣O␣O␣O␣O␣\␣\ /␣/␣O␣O␣O␣O␣O␣O␣O␣O␣O␣\␣\ \␣\␣O␣O␣O␣O␣O␣O␣O␣O␣O␣/␣/ ␣\␣\␣O␣O␣O␣O␣O␣O␣O␣O␣/␣/ ␣␣\␣\␣O␣O␣O␣O␣O␣O␣O␣/␣/ ␣␣␣\␣\␣O␣O␣O␣O␣O␣O␣/␣/ ␣␣␣␣\␣\␣_␣_␣_␣_␣_␣/␣/ ␣␣␣␣␣\␣_␣_␣_␣_␣_␣_␣/ ␣␣␣␣␣␣|␣␣␣␣␣_␣␣␣␣␣| ␣␣␣␣␣␣|␣␣␣␣|_|␣␣␣␣| ␣␣␣␣␣␣|␣␣␣␣␣␣␣␣␣␣␣| ␣␣␣␣␣␣|␣␣␣␣␣␣␣␣␣␣␣| ␣␣␣␣␣␣|␣␣␣␣␣␣␣␣␣␣␣| ␣␣␣␣␣␣|_␣_␣_␣_␣_␣_|
   Program Specification
1. The program first prompts the user for the side length 𝑛.
2. If 𝑛 is invalid (not between 3 and 29), the program prints an error message and terminates.
3. Print the machine capacity 𝑐, given by equation (1).
4. Prompt the user for the w**4;w**5;w**0;𝑐𝑘 of gumballs.
5. If w**4;w**5;w**0;𝑐𝑘 is invalid (not between ⌊𝑐/2⌋ and 𝑐), print an error message and terminate the program.
6. Print the gumball machine using loops and conditionals. This step comprises more subtasks like:
a. Determine the left padding, i.e., how many spaces to print before /, \ or | per row. b. Print the hexagonal part.
c. Align the current stock of gumballs properly inside the container.
d. Print the square part.
7. Prompt the user for the quantity w**2; to buy.
8. If w**2; is invalid (not between 1 and w**4;w**5;w**0;𝑐𝑘), print an error message and go back to step 6.
9. Deduct w**2; from w**4;w**5;w**0;𝑐𝑘.
10. If w**4;w**5;w**0;𝑐𝑘 > 0, go back to step 6.
11. Print the message "Sold out!" finally.
Note two important points:
• (Regarding 6.b) For a hexagon container full of gumballs, the number of gumballs varies by one
when going from one row to the next, except the two rows in the middle of the hexagon.
• (Regarding 6.c) Gumballs are dispensed or “consumed” in a top-to-bottom, left-to-right manner. The gumballs on the top row should be aligned to the right if their count is less than the row’s capacity (see Figure 1 again). Once consumed, the letter 'O' denoting a gumball will be replaced
by a space character.
Assumptions: You can assume that all user inputs are always entered as integers. The program behavior beyond this assumption can be indeterminate and your program behavior can be different from our sample program.
Copyright © 2024 CSE, CUHK Page 3 of 8

CSCI1120 Introduction to Computing Using C++, Fall 2024/25
Department of Computer Science and Engineering, The Chinese University of Hong Kong
Restrictions: You are NOT allowed to use any arrays, vectors, or any other data containers in this assignment. You may use the string class (e.g., to store a line of characters if you see fit) but you cannot use its at() method or the subscript operator [] to traverse the individual characters of a string. Defining your own functions or macros is allowed but not mandatory.
Sample Runs
In the following sample runs, the blue numbers after ':' are user inputs and the other text is the program printout. You can try the provided sample program for other inputs. Your program printout shall be exactly the same as the sample program (same text, symbols, letter case, spacings, etc.). Note that there is a space after the ':' included in each input prompt.
    Enter side length: -1↵ Invalid side length!
Enter side length: 30↵ Invalid side length!
Enter side length: 4↵
Machine capacity: 21
Enter gumball stock: 9↵
Too few / many gumballs to load!
Enter side length: 4↵
Machine capacity: 21
Enter gumball stock: 22↵
Too few / many gumballs to load!
Enter side length: 6↵
Machine capacity: 65
Enter gumball stock: 31↵
Too few / many gumballs to load!
Enter side length: 4↵ Machine capacity: 21 Enter gumball stock: 10↵
____ /___\ // \\ // \\ // O\\ \\OOOOO// \\OOOO// \\___// \____/ |_|
| |_| | ||
|_ _ _ _|
Enter quantity to buy: 1↵ Copyright © 2024 CSE, CUHK
Page 4 of 8
          
CSCI1120 Introduction to Computing Using C++, Fall 2024/25
Department of Computer Science and Engineering, The Chinese University of Hong Kong
____ /___\ // \\ // \\ // \\ \\OOOOO// \\OOOO// \\___// \____/ |_|
| |_| | ||
|_ _ _ _| Enter quantity to ____ /___\ // \\ // \\ // \\ \\ // \\OOOO// \\___// \____/ |_|
| |_| | ||
|_ _ _ _| Enter quantity to Invalid quantity! ____ /___\ // \\ // \\ // \\ \\ // \\OOOO// \\___// \____/ |_|
| |_| | ||
|_ _ _ _| Enter quantity to ____ /___\ // \\ // \\ // \\ \\ // \\ // \\___// \____/ |_|
| |_| | ||
|_ _ _ _|
Sold out!
buy: 5↵
buy: 5↵
buy: 4↵
 Copyright © 2024 CSE, CUHK
Page 5 of 8

CSCI1120 Introduction to Computing Using C++, Fall 2024/25
Department of Computer Science and Engineering, The Chinese University of Hong Kong
 Enter side length: 5↵ Machine capacity: 40 Enter gumball stock: 25↵
_____ /____\ // \\ // \\ // \\ //OOOOOOO\\ \\OOOOOOO// \\OOOOOO// \\OOOOO// \\____// \_____/ |_|
| |_| | || ||
|_ _ _ _ _|
Enter quantity to buy: 26↵ Invalid quantity!
_____ /____\ // \\ // \\ // \\ //OOOOOOO\\ \\OOOOOOO// \\OOOOOO// \\OOOOO// \\____// \_____/ |_|
| |_| | || ||
|_ _ _ _ _|
Enter quantity to buy: 0↵ Invalid quantity!
_____ /____\ // \\ // \\ // \\ //OOOOOOO\\ \\OOOOOOO// \\OOOOOO// \\OOOOO// \\____// \_____/ |_|
| |_| | || ||
|_ _ _ _ _|
Enter quantity to buy: 10↵ Copyright © 2024 CSE, CUHK
Page 6 of 8

CSCI1120 Introduction to Computing Using C++, Fall 2024/25
Department of Computer Science and Engineering, The Chinese University of Hong Kong
_____ /____\ // \\ // \\ // \\ // \\ \\ OOOO// \\OOOOOO// \\OOOOO// \\____// \_____/ |_|
| |_| | || ||
|_ _ _ _ _|
Enter quantity to buy: 5↵ _____
/____\ // \\ // \\ // \\ // \\ \\ // \\ OOOOO// \\OOOOO// \\____// \_____/ |_|
| |_| | || ||
|_ _ _ _ _|
Enter quantity to buy: 10↵ _____
/____\ // \\ // \\ // \\ // \\ \\ // \\ // \\ // \\____// \_____/ |_|
| |_| | || ||
|_ _ _ _ _|
Sold out!
 Copyright © 2024 CSE, CUHK
Page 7 of 8

CSCI1120 Introduction to Computing Using C++, Fall 2024/25
Department of Computer Science and Engineering, The Chinese University of Hong Kong
Submission and Marking
§ Your program file name shall be gumball.cpp. Submit the file in Blackboard (https://blackboard.cuhk.edu.hk/).
§ Insert your name, student ID, and e-mail as comments at the beginning of your source file. // CSCI1120 Assignment 2
   // Name:
   // Student ID:
   // Email: (the one that you check most often)
§ You can submit your assignment multiple times. Only the latest submission counts.
§ Your program shall be free of compilation errors and warnings when built in VS Community 2022.
§ Your program shall include suitable comments as documentation.
§ Do NOT share your work to others and do NOT plagiarize. Both senders and plagiarists shall be
penalized.
           Copyright © 2024 CSE, CUHK Page 8 of 8

請(qǐng)加QQ:99515681  郵箱:99515681@qq.com   WX:codinghelp





 

掃一掃在手機(jī)打開當(dāng)前頁(yè)
  • 上一篇:代做COMP3230、代寫c/c++編程設(shè)計(jì)
  • 下一篇:代寫ECON 3E03、代做R設(shè)計(jì)編程
  • 無(wú)相關(guān)信息
    合肥生活資訊

    合肥圖文信息
    急尋熱仿真分析?代做熱仿真服務(wù)+熱設(shè)計(jì)優(yōu)化
    急尋熱仿真分析?代做熱仿真服務(wù)+熱設(shè)計(jì)優(yōu)化
    出評(píng) 開團(tuán)工具
    出評(píng) 開團(tuán)工具
    挖掘機(jī)濾芯提升發(fā)動(dòng)機(jī)性能
    挖掘機(jī)濾芯提升發(fā)動(dòng)機(jī)性能
    海信羅馬假日洗衣機(jī)亮相AWE  復(fù)古美學(xué)與現(xiàn)代科技完美結(jié)合
    海信羅馬假日洗衣機(jī)亮相AWE 復(fù)古美學(xué)與現(xiàn)代
    合肥機(jī)場(chǎng)巴士4號(hào)線
    合肥機(jī)場(chǎng)巴士4號(hào)線
    合肥機(jī)場(chǎng)巴士3號(hào)線
    合肥機(jī)場(chǎng)巴士3號(hào)線
    合肥機(jī)場(chǎng)巴士2號(hào)線
    合肥機(jī)場(chǎng)巴士2號(hào)線
    合肥機(jī)場(chǎng)巴士1號(hào)線
    合肥機(jī)場(chǎng)巴士1號(hào)線
  • 短信驗(yàn)證碼 豆包 幣安下載 AI生圖 目錄網(wǎng)

    關(guān)于我們 | 打賞支持 | 廣告服務(wù) | 聯(lián)系我們 | 網(wǎng)站地圖 | 免責(zé)聲明 | 幫助中心 | 友情鏈接 |

    Copyright © 2025 hfw.cc Inc. All Rights Reserved. 合肥網(wǎng) 版權(quán)所有
    ICP備06013414號(hào)-3 公安備 42010502001045

    99爱在线视频这里只有精品_窝窝午夜看片成人精品_日韩精品久久久毛片一区二区_亚洲一区二区久久

          免费欧美电影| 99精品99久久久久久宅男| 亚洲午夜精品福利| 欧美极品一区二区三区| 国产午夜精品在线| 午夜视黄欧洲亚洲| 国产精品久久精品日日| 一区二区三区成人精品| 欧美日韩精品在线播放| av不卡在线观看| 欧美日韩精品高清| 日韩视频在线免费| 欧美日韩国产在线看| 日韩午夜电影av| 欧美日韩精品免费观看视频完整| 91久久一区二区| 欧美高清视频一区二区三区在线观看 | 欧美日韩国产在线播放| 亚洲精品少妇30p| 欧美日韩伦理在线| 一区二区日韩| 欧美三级黄美女| 午夜亚洲激情| 激情亚洲网站| 免费观看欧美在线视频的网站| 亚洲国产第一| 欧美日韩国产美| 在线亚洲欧美视频| 国产精品专区第二| 久久av一区二区三区| 1000部国产精品成人观看| 免费成人黄色| 一区二区三欧美| 国产麻豆日韩| 久久综合中文字幕| 99av国产精品欲麻豆| 国产精品久久久久毛片软件| 久久激情五月丁香伊人| 亚洲国产欧美久久| 欧美精品麻豆| 91久久精品美女高潮| 欧美日韩一二三区| 欧美一区二区在线播放| 最新中文字幕一区二区三区| 欧美网站在线观看| 欧美中文在线观看国产| 亚洲激情视频在线| 国产精品二区二区三区| 久久五月激情| 亚洲午夜av电影| 一区二区自拍| 国产精品毛片a∨一区二区三区|国| 久久er99精品| 99爱精品视频| 一区二区在线免费观看| 欧美色图五月天| 久久综合网hezyo| 亚洲一区二区三区高清| 影音先锋亚洲一区| 国产精品亚洲美女av网站| 欧美国产激情| 欧美在线中文字幕| 日韩一级精品视频在线观看| 国产一区二三区| 欧美日韩中文字幕| 奶水喷射视频一区| 久久国产综合精品| 亚洲无限av看| 亚洲免费高清| 亚洲国产女人aaa毛片在线| 国产欧美欧美| 欧美午夜欧美| 欧美国产精品中文字幕| 久久精品中文| 亚洲欧美日韩久久精品| 亚洲人体1000| 亚洲国产精品久久人人爱蜜臀| 国产乱理伦片在线观看夜一区| 欧美日韩国产专区| 免费不卡视频| 久久人人看视频| 欧美一级视频精品观看| 亚洲一区二区在| 国产精品99久久不卡二区 | 国产精品久久久久久久久| 男人的天堂亚洲| 免费成人高清| 老牛影视一区二区三区| 久久久久久久尹人综合网亚洲 | 久久久一区二区| 久久国产欧美| 久久久久久亚洲精品中文字幕| 午夜影视日本亚洲欧洲精品| 亚洲图色在线| 亚洲视频在线二区| 亚洲欧美春色| 性伦欧美刺激片在线观看| 亚洲欧美精品在线观看| 亚洲欧美在线一区| 欧美一区二区三区另类| 欧美一级一区| 久久国产加勒比精品无码| 久久成人免费电影| 久久久欧美精品sm网站| 老色鬼久久亚洲一区二区| 久久综合图片| 欧美成人午夜视频| 欧美人妖在线观看| 欧美日韩一二三四五区| 欧美日韩综合另类| 国产精品免费视频xxxx| 国产精品综合不卡av| 国产一区二区三区四区老人| 黄色综合网站| 亚洲三级免费| 亚洲欧美视频| 久久免费黄色| 欧美日韩999| 国产欧美视频一区二区| 狠狠久久婷婷| 亚洲日本va午夜在线影院| 一本色道久久88亚洲综合88| 午夜精品美女久久久久av福利| 久久久久久国产精品一区| 欧美91视频| 欧美亚男人的天堂| 韩日在线一区| 在线视频你懂得一区| 亚洲欧美亚洲| 免费在线观看日韩欧美| 欧美日韩精品国产| 国产综合色产在线精品| 日韩一级黄色av| 欧美一区二区三区四区高清 | 激情成人中文字幕| 亚洲理论在线| 欧美一区二区三区播放老司机| 蜜臀久久久99精品久久久久久 | 免费久久精品视频| 国产精品久久久久一区二区三区| 在线播放豆国产99亚洲| 亚洲婷婷国产精品电影人久久| 久久国产乱子精品免费女| 欧美日韩高清区| 国产亚洲精品久久久久动| 亚洲乱码国产乱码精品精98午夜| 亚洲欧美日韩国产一区二区三区| 免费看成人av| 国产亚洲一级高清| 正在播放欧美视频| 你懂的视频一区二区| 国产欧美视频一区二区| 一区二区三区成人精品| 猛男gaygay欧美视频| 国产嫩草一区二区三区在线观看| 亚洲经典在线看| 久久久久久91香蕉国产| 国产精品视屏| 亚洲一区中文| 欧美激情久久久| 亚洲第一偷拍| 久久久久成人精品免费播放动漫| 欧美性猛交99久久久久99按摩| 亚洲激情在线观看视频免费| 久久国产一区二区| 国产欧美精品一区二区三区介绍| 亚洲视频在线播放| 欧美日韩国产小视频| 91久久国产综合久久| 蜜臀va亚洲va欧美va天堂| 狠狠做深爱婷婷久久综合一区| 亚洲欧美成人一区二区三区| 欧美午夜剧场| 亚洲一区二区成人| 国产精品国产三级国产专播品爱网 | 国产精品黄视频| 亚洲桃花岛网站| 欧美日韩一区在线观看视频| 亚洲欧洲久久| 欧美激情国产精品| 亚洲精品老司机| 欧美日韩国产影院| 一区二区三区产品免费精品久久75| 欧美成人激情在线| 亚洲国产综合在线| 欧美精品v国产精品v日韩精品| 亚洲黄色高清| 欧美激情国产高清| 亚洲九九九在线观看| 欧美日韩免费观看中文| 一区二区三区毛片| 国产精品s色| 午夜免费在线观看精品视频| 国产麻豆精品theporn| 欧美一区二区免费观在线| 国产日韩欧美中文在线播放| 久久久久久午夜| 亚洲人成网站在线观看播放| 欧美激情一区在线观看| 99精品福利视频|