I have a string that I need to keep subtracting from the beginning while the letters continuously move as well. For example:
ABC DEF GHI JK needs to look like this
BCD EFG HIJ K and then
CDE FGH IJK
I have some code, but the letters are not moving individually:
int main()
{
string code, default_Code;
default_Code = "TCAATGTAACGCGCTACCCGGAGCTCTGGGCCCAAATTTCATCCACT";
start_C = "AUG";
code.reserve(100);
int i = 0, a = 0, c =0;
char choice;
for (int j = 3; j < code.length(); j += 4) // Creating space between 3 letters
{
code.insert(j, 1, ' ');
}
do {
i = 0;
do { // Looping to create an open reading frame.
for (int b = 0; b*3 < code.length(); b++) { // moving through the code
for (int a = 0; a < 3; a++) {
cout << code[(a + b*3) + i];
}
}
i++;
cout << endl;
} while (i < 3);
reverse(code.rbegin(), code.rend()); // Reversing to create the second set reading frame.
c++;
cout << endl;
} while (c < 2);
return 0;
}
If you really want to put space characters into the string, instead of just inserting them in the output, you could do something like this:
EDIT> To respond to the comments below:
If you try inserting this code before the printf statement…
…you’ll see that code.find(“ATC”) does not find “A TC” or “AT C”. It doesn’t find it until the third line of output when “ATC” appears in the string without any spaces in between the letters. I have spaces inserted the actual string data just as your original code did.