Answer to Question #47567 in C++ for krad

Question #47567
3. Write a program which produces the given sequence nos. (in alternate arrangement descending ) using the three looping statements:
1,5,2,4,3,3,4,2,5,1
1
Expert's answer
2014-10-13T03:52:21-0400
Solution.
Code
#include <iostream>
#include <string>

using namespace std;

int main() {
stringdirect;
stringinverse;

// Input
cin >> direct;
inverse = direct;
// Inversing
for (int i = 0; i < direct.length(); i++) {
inverse[i] = direct[direct.length() - 1 - i];
}

// Output
cout << direct << "," << inverse;

return 0;
}
Result
1,5,2,4,3
1,5,2,4,3,3,4,2,5,1


Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS