Answered step by step
Verified Expert Solution
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++
#include
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. #includeStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started