G
G
Goddamnboy2019-05-09 13:33:40
C++ / C#
Goddamnboy, 2019-05-09 13:33:40

How to implement the algorithm?

I created 2 arrays, in one the user enters a string, and the other array outputs the inverted one. I want to do this through a loop (the last element of the first array is written to as the first element of the 2nd array)

char stroka[6];
char stroka2[6];
for (int i = 5; i>=0; i--){

}

Answer the question

In order to leave comments, you need to log in

3 answer(s)
S
svetlov97, 2019-05-09
@Goddamnboy

What programming language?
I'll move my answer:
Except char[...] is an array of characters, not a string. With a string I think it will work

#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main() {
    string str = "любая строка";
    reverse(str.begin (), str.end ());
    cout << str;
}

Output: acorts jabul

M
MamaLuyba, 2019-05-09
@MamaLuyba

I suggest the implementation:
1. open google
2. enter "#lang_name# line reverse"
3. ?????
4. PROFIT!

P
pfemidi, 2019-05-09
@pfemidi

It is necessary to write in a loop the last element of the first array as the first element of the second array, after the penultimate element of the first array as the second element of the second array, and so on until the array ends. Profit!
What is the question, what is the answer.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question