Write output of following piece of code: b) #include #include using namespace std; MIRPUR int main() const
Fantastic news! We've Found the answer you've been seeking!
Question:
Write output of following piece of code:
Transcribed Image Text:
b) #include <string.h> #include <iostream> using namespace std; MIRPUR int main() const int MAX_NUM = 9; const int MAX_NOS = 9; const int MAX_SUM_VAL = 100; int n, s, dp[MAX_NOS + 1][MAX_NUM + 1][MAX_SUM_VAL + 1]; long long SUM_VAL = 0; memset(dp, 0, sizeof(dp)); for (int i = 0; i < MAX_NUM; i++) dp[1][i][] = 1; for (int N = 2; N <= MAX_NOS; N++) for (int i = 1; i <= MAX_NUM; 1++) for (int j = 1; j <= MAX_SUM_VAL; j++) if ( -i >= 0) { for (int k = 0; k< i; k++) { dp[N][i[J] += dp[N -1][k][j-i]; cin >> n >> s; SUM_VAL = 0; for (int i = 0; i <= MAX_NUM; i++) SUM_VAL += dp[n][i][s]; } cout << "Number of digits " <<n << " and Sum = " << s; cout << "InNumber of pairs: " <«SUM_VAL << endl; return 0; b) #include <string.h> #include <iostream> using namespace std; MIRPUR int main() const int MAX_NUM = 9; const int MAX_NOS = 9; const int MAX_SUM_VAL = 100; int n, s, dp[MAX_NOS + 1][MAX_NUM + 1][MAX_SUM_VAL + 1]; long long SUM_VAL = 0; memset(dp, 0, sizeof(dp)); for (int i = 0; i < MAX_NUM; i++) dp[1][i][] = 1; for (int N = 2; N <= MAX_NOS; N++) for (int i = 1; i <= MAX_NUM; 1++) for (int j = 1; j <= MAX_SUM_VAL; j++) if ( -i >= 0) { for (int k = 0; k< i; k++) { dp[N][i[J] += dp[N -1][k][j-i]; cin >> n >> s; SUM_VAL = 0; for (int i = 0; i <= MAX_NUM; i++) SUM_VAL += dp[n][i][s]; } cout << "Number of digits " <<n << " and Sum = " << s; cout << "InNumber of pairs: " <«SUM_VAL << endl; return 0;
Expert Answer:
Related Book For
Statistics for Business and Economics
ISBN: 978-0132930192
8th edition
Authors: Paul Newbold, William Carlson, Betty Thorne
Posted Date:
Students also viewed these programming questions
-
Write output of following piece of code a) #include #include using namespace std; string arith_geo_sequence(int nums[], const int size) { int diff_arith = 0, diff_geo = 0; bool arith_flag = true,...
-
Hong Kongs Four Seas Fishballs is the chosen case for this term. Four Seas Fishballs which was found in 1977 is one of the famous food productions in Hong Kong. Taking the role as a marketing manager...
-
Write output of following program. #include using namespace std; void repchar(char, int); int main() { repchar(-, 43); cout << Data type Range << endl; repchar(=, 23); cout << char...
-
Kebri LTD. sells Radios and Televisions. They have recorded their monthly revenue as follows. Revenue(Y) 330 180 209 390 391 304 347 461 538 610 Radio units (X1) 55 71 92 113 134 156 171 193 219 232...
-
It has been a hectic year at Abdalla Lodge. In January 20X4, Myesha Kind incorporated Abdalla as a not- for- profit organization. Its mandate is to provide counselling services for troubled youth....
-
ASCII, Unicode, and EBCDIC are, of course, not the only possible codes. The Sophomites from the planet Collegium use the rather strange codeshownin Figure E4.1. There are only thirteen characters in...
-
Which of the following is a function of an AIS? a. reducing the need to identify a strategy and strategic position b. transforming data into useful information c. allocating organizational resources...
-
The payroll records of Speedy Software show the following information about Marsha Gottschalk, an employee, for the weekly pay period ending September 30, 2013. Gottschalk is single and claims one...
-
Research and discuss the reflection/post on --- "The latest issues regarding trademarks, patents, and copyrights." What about companies attempting to patent business plans? Life forms? Where will the...
-
Hurzdan, Inc., has a 32-day average collection period and wants to maintain a minimum cash balance of $20 million, which is what the company currently has on hand. The company currently has a...
-
Assume the number of physical damage losses for houses as a result of Hurricane Irma in Barbuda is normally distributed with a mean of 400 and a standard deviation of 80. What is the probability...
-
Solve lim x64 - - 8 64 Give your answer to at least three decimal places: 00
-
In a computer network, where every router connects to every other router, each device has n - 1 number of connections. There are a total of n (n - 1) / 2 number of connections. This is because each...
-
solve lim x 8 - x-64 x 64 - Give your answer to at least three decimal places: 00
-
4. When we have a probability function, we can calculate average of a variable. So, e-Ei for example if the probability of a molecule in the energy state E is p = then the average energy E is: Ele-E...
-
"What ways do you think we could implement performance improvement in healthcare? "
-
Gross Domestic Product Industrial Unemployment Forecast Forecast Production Rate Country Australia Latest Qtr Qtr* 2007e 2008e Recent Qtr Latest 4.3% 3.8% 4.1% 3.5% 4.6% 4.2% Japan United States 1.6%...
-
DEPARTMENT DATA EMPLOYEE DATA EmployeeNumber FirstName Mary Rosalie Richard George Alan 3 4 5 7 8 9 855555ES 12 13 14 15 16 17 Create the database tables in SQL or ACCESS: 18 19 20 PROJECT DATA Ken...
-
Compute SSR, SSE, s2e, and the coefficient of determination, given the following statistics computed from a random sample of pairs of X and Y observations. a. (y-9)-100,000, R2 = 0.50, " = 52 b. ...
-
A consumer product that has flourished in the last few years is bottled natural spring water. Jon Thorne is the CEO of a company that sells natural spring water. He has requested a report of the...
-
A college has 3,200 undergraduate students and 800 graduate students. Researchers are interested in the amount of money spent in a year on textbooks by these students. Initially, simple random...
-
A constructive partnership between the chair and the chief executive is vital to every nonprofit. Why is this true or does it always matter?
-
For the most part, chairs change regularly, but the chief executive stays in place for a longer period of time. How can this situation affect the dynamics of the two positions?
-
Discuss the ways in which a federated system can be formed. What are the key roles of the national board and the chapter boards? How do the national staff and the chapter staff best relate to this...
Study smarter with the SolutionInn App