Problem 1: Simple strings & loops Given a string and an int n, create made of the first n characters of th

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter7: Characters, Strings, And The Stringbuilder
Section: Chapter Questions
Problem 12RQ
icon
Related questions
Question

need help with this c++ for loop problem

/**
*
*
*
*
Problem 1: Simple strings & loops
Given a string and an int n, create a new string
made of the first n characters of the original
string, followed by the first n-1 characters of
the original string, and so on. You may assume
that n is between 0 and the length of the string,
inclusive (i.e. n >= 0 and n <= str.length())
}
Some examples:
"Chocolate",
"Chocolate",
4 -> "ChocChoChC"
3 -> "ChoChC"
"Ice Cream", 2 -> "IcI"
*/
string decreasing (const string& str, int n)
{
string result = "not done";
// Add your code here
for()
return result;
Transcribed Image Text:/** * * * * Problem 1: Simple strings & loops Given a string and an int n, create a new string made of the first n characters of the original string, followed by the first n-1 characters of the original string, and so on. You may assume that n is between 0 and the length of the string, inclusive (i.e. n >= 0 and n <= str.length()) } Some examples: "Chocolate", "Chocolate", 4 -> "ChocChoChC" 3 -> "ChoChC" "Ice Cream", 2 -> "IcI" */ string decreasing (const string& str, int n) { string result = "not done"; // Add your code here for() return result;
Expert Solution
steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Computational Systems
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning