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爱在线视频这里只有精品_窝窝午夜看片成人精品_日韩精品久久久毛片一区二区_亚洲一区二区久久

          9000px;">

                欧美日韩在线免费视频| 欧美激情综合在线| 国产精品的网站| 99国产精品99久久久久久| 洋洋av久久久久久久一区| 欧美一区二区女人| 丁香另类激情小说| 亚洲成人777| 久久综合狠狠综合久久激情| 91精品麻豆日日躁夜夜躁| 亚洲成人7777| 亚洲欧洲日本在线| 国产一区 二区 三区一级| 在线观看日韩精品| 日韩精品一二区| 国产女人aaa级久久久级| 欧美日韩一二三| 国产成人精品网址| 日本一不卡视频| 国产精品污网站| 88在线观看91蜜桃国自产| 99在线精品观看| 国产精品一区二区不卡| 日韩精品电影一区亚洲| 国产精品初高中害羞小美女文| 欧美巨大另类极品videosbest| 本田岬高潮一区二区三区| 麻豆国产91在线播放| 亚洲一区二区三区国产| 国产精品亲子伦对白| 26uuu色噜噜精品一区二区| 欧美日韩极品在线观看一区| 91小视频免费看| 国产很黄免费观看久久| 六月丁香婷婷久久| 天堂在线亚洲视频| 亚洲精品成人在线| 国产精品福利一区| 国产精品乱码人人做人人爱| 久久久久国产精品人| 日韩一级免费观看| 欧美一级爆毛片| 91精品国产综合久久久蜜臀图片| 91福利视频在线| 色婷婷av一区二区三区软件 | 99综合电影在线视频| 国产精品亚洲第一| 国产成人av电影在线播放| 国产伦理精品不卡| 国产传媒欧美日韩成人| 国产激情视频一区二区在线观看| 国产一区二区三区av电影 | 欧美一级片免费看| 欧美日韩久久一区二区| 欧美日韩色综合| 欧美精品国产精品| 欧美电影免费观看高清完整版在| 91精品免费在线| 日韩精品最新网址| 久久久99久久| 国产精品不卡一区| 亚洲女同一区二区| 亚洲国产精品一区二区久久| 亚洲成人免费av| 日本欧美韩国一区三区| 国内精品写真在线观看| 不卡的电视剧免费网站有什么| 99国产麻豆精品| 欧美亚洲高清一区二区三区不卡| 欧美精品一卡二卡| 国产亚洲欧美中文| 亚洲综合久久久| 蜜桃视频在线一区| www.日韩大片| 欧美日韩五月天| 精品国产第一区二区三区观看体验| 国产网红主播福利一区二区| 亚洲精品国产精华液| 精品一区二区影视| 91浏览器打开| 欧美岛国在线观看| 亚洲精品中文字幕乱码三区| 亚洲午夜精品在线| 免费人成精品欧美精品| 成人爽a毛片一区二区免费| 欧美性受xxxx| 国产日韩精品一区二区浪潮av| 一区二区激情小说| 国产精品综合网| 欧美日韩中文字幕一区二区| 欧美精品一区男女天堂| 一区二区日韩av| 国产精品一区二区久久不卡| 欧美精品一级二级| 欧美激情一区二区在线| 青草av.久久免费一区| 一本久久精品一区二区| 中文无字幕一区二区三区| 日本欧洲一区二区| 91久久精品一区二区| 中文字幕乱码日本亚洲一区二区 | 国产精品无遮挡| 美女国产一区二区三区| 欧美自拍丝袜亚洲| 亚洲婷婷在线视频| 不卡的av电影在线观看| 欧美成人女星排名| 性做久久久久久久久| 色婷婷精品久久二区二区蜜臂av | 青青青伊人色综合久久| 在线这里只有精品| 亚洲日本免费电影| 成人高清视频免费观看| 欧美精品一区二区在线播放| 蜜臀久久99精品久久久画质超高清| 欧美私人免费视频| 亚洲一区二区三区中文字幕在线 | 亚洲欧美精品午睡沙发| 成人一区在线观看| 国产精品网曝门| 成人激情免费视频| 国产精品美女久久久久aⅴ国产馆| 精品夜夜嗨av一区二区三区| 日韩美女视频一区二区在线观看| 日韩专区在线视频| 8v天堂国产在线一区二区| 日本不卡一二三区黄网| 欧美一区二区三区在线视频| 免费黄网站欧美| 精品国产91洋老外米糕| 精品亚洲成a人| 欧美极品xxx| 色综合中文综合网| 美女性感视频久久| 欧美精品一区二区三区视频| 久久se这里有精品| 国产清纯美女被跳蛋高潮一区二区久久w | 久久网站最新地址| 亚洲丶国产丶欧美一区二区三区| 欧美日韩aaaaa| 麻豆精品久久久| 26uuu国产电影一区二区| 国产成人精品午夜视频免费| 国产精品第五页| 欧美精品久久久久久久久老牛影院| 日日夜夜免费精品| 久久奇米777| 91免费在线视频观看| 午夜精品久久久久久久蜜桃app| 欧美精品在欧美一区二区少妇| 狠狠色丁香久久婷婷综合_中 | 91精品国产高清一区二区三区| 美女mm1313爽爽久久久蜜臀| 国产欧美一区二区三区鸳鸯浴| 色悠久久久久综合欧美99| 日韩电影免费在线| 国产精品久久久久四虎| 欧美一区二区三区在线观看| 99久久国产免费看| 美女网站在线免费欧美精品| 亚洲色图在线播放| 欧美一区二区成人6969| 97精品久久久午夜一区二区三区 | 中文字幕日韩av资源站| 91精品国产综合久久香蕉的特点 | 亚洲男人的天堂av| 欧美电影精品一区二区| 日本韩国视频一区二区| 国产精品99久| 乱中年女人伦av一区二区| 亚洲乱码中文字幕| 国产日韩成人精品| 日韩免费视频线观看| 欧美人与z0zoxxxx视频| 99国产精品99久久久久久| 国产综合久久久久影院| 日韩vs国产vs欧美| 亚洲曰韩产成在线| 国产精品电影一区二区| 久久久久久99久久久精品网站| 欧美一区二区在线免费观看| 欧美熟乱第一页| 日本高清不卡在线观看| 91视频在线观看免费| 成人理论电影网| 国产高清亚洲一区| 国产麻豆精品视频| 国产麻豆91精品| 国产毛片精品一区| 久久99久国产精品黄毛片色诱| 亚洲成av人片在www色猫咪| 亚洲欧美成人一区二区三区| 国产精品的网站| 亚洲色欲色欲www| 亚洲欧美日本在线| 亚洲影视在线播放| 午夜私人影院久久久久| 亚洲午夜国产一区99re久久| 亚洲综合色成人| 爽好久久久欧美精品|