Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

in c++ #include using namespace std; const int arrayLength = 1000; void noCuts(int array[], int size, int cuts); int main() { int array[arrayLength]; int n

in c++ image text in transcribedimage text in transcribed

image text in transcribed

#include using namespace std;

const int arrayLength = 1000;

void noCuts(int array[], int size, int cuts);

int main() {

int array[arrayLength]; int n = 0; cin>>n;

noCuts(array, 1000, n);

for (int i = 0; i

void noCuts(int array[], int size, int cuts) {

}

Suppose you have a cake (or a pizza) and you want to use a knife to have long straight cuts through it. Your line cuts DO NOT meet at a central point. . With one long straight cut, you cut the cake into two pieces. With two long straight cuts, you cut the cake into four pieces. With three long straight cuts, you cut the cake into seven pieces, and so on. The figure below illustrates: Maximal number of pieces formed when slicing a pancake with n cuts 1 4 7 11 16 To calculate the number of pieces you can make with n cuts, you can use the following equation: noCuts = na+n+2 2 You are required to write a function that takes as input the maximum number of cuts n, then computes and stores in an array the number of cuts you will have as you go cutting your cake from 0 cuts to n cuts. However, your function will not return the number of cuts. Instead, it will return an array that holds the difference between the number of cuts done this way, and the number of cuts if your lines go through the center of the cake. 1 O Type here to search --- I/O Input: One line containing the number of straight cuts that do not pass through the center Output: The difference between the total number of pieces if the cuts did not pass through the center, and if they passed through the center. The line will display the difference as you progress cutting the cake. Sample Testcase 0: Input: 5 Output: 000136 Explanation If your straight cuts do not pass throught the center, then you will have 1, 2, 4, 7, 11, 16 pieces. If your straight cuts always pass through the center, then you will have 1, 2, 4, 6, 8, 10 pieces. The function returns the array that holds the absolute difference in between. #include O Type here to search IT 1 #include using namespace std; 2 3 4 const int arrayLength = 1000; 5 6 void noCuts(int array[], int size, int cuts); 7 8 int main() { 9 10 11 int array(arrayLength]; int n = 0; cin>>n; 12 13 14 noCuts(array, 1000, n); 15 16 for (int i = 0; i

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Databases And Information Systems 1 International Baltic Conference Dbandis 2020 Tallinn Estonia June 19 2020 Proceedings

Authors: Tarmo Robal ,Hele-Mai Haav ,Jaan Penjam ,Raimundas Matulevicius

1st Edition

303057671X, 978-3030576714

More Books

Students also viewed these Databases questions

Question

mple 10. Determine d dx S 0 t dt.

Answered: 1 week ago