#include
using namespace std;
//Barry Bruin is learning about recursion, and attempted to wri...
Computers and Technology, 08.10.2020 09:01 jorozco3209
#include
using namespace std;
//Barry Bruin is learning about recursion, and attempted to write a
//program that recursively determines whether a provided integer's
//digits are in non-decreasing order (that is, they are in increasing
//order, but not necessarily strictly increasing order). As is, the
//program currently always outputs false, asserting that the digits
//are not in non-decreasing order. Run the program with several
//different inputs to verify this
//Your job is to fix the code so that it gives the correct output for
//all possible inputs. Only make changes where the code indicates
//that they should be made: you should not change the main function,
//nor the start of the helper function. You may not use for, while,
//do while, or goto.
bool increasing(int a)
{
if (a > 0) {
//if the recursive call fails, don't bother to check further.
if (!increasing (a/10)) return false;
//the least significant digit
int last = a % 10;
//the second least significant digit, 0 if a < 10
int prev = (a / 10) % 10;
//make your changes only below this line.
if (prev <= last) return true;
return false;
}
return false;
}
//do not change the main function.
int main (int argc, char* argv[])
{
int x;
cin >> x;
cout << increasing(x) << endl;
return 0;
}
Answers: 1
Computers and Technology, 21.06.2019 16:00
What does josh silverman name as the most important aspect of managing finances?
Answers: 2
Computers and Technology, 23.06.2019 10:50
Your friend kayla is starting her own business and asks you whether she should set it up as a p2p network or as a client-server network. list three questions you might ask to kayla decide which network to use and how her answers to those questions would affect your recommendation.
Answers: 2
Computers and Technology, 23.06.2019 12:50
Which syntax error in programming is unlikely to be highlighted by a compiler or an interpreter? a variable name misspelling a missing space a comma in place of a period a missing closing quotation mark
Answers: 1
Computers and Technology, 23.06.2019 22:30
Jamie has to enter the names, employee id’s, and income of a group of employees into a worksheet. which option will jamie use to describe the data
Answers: 3
Biology, 01.12.2020 22:40
Mathematics, 01.12.2020 22:40
Mathematics, 01.12.2020 22:40
Mathematics, 01.12.2020 22:40
Mathematics, 01.12.2020 22:40
Mathematics, 01.12.2020 22:40
Mathematics, 01.12.2020 22:40
Mathematics, 01.12.2020 22:40
Mathematics, 01.12.2020 22:40
Chemistry, 01.12.2020 22:40
History, 01.12.2020 22:40
Mathematics, 01.12.2020 22:40
Spanish, 01.12.2020 22:40
Mathematics, 01.12.2020 22:40