Hello everybody, sorry for my english, I'm french.
I'm also a beginner in C++
I have a question. I need to reverse a sequence of letters
In one octet, there are 4 letters (2 bits by letter)
For example, I have this :
ATCG CTTA AATT
And I need to have this :
TTAA ATTC GCTA
But, first, I just want to reverse the octet to obtain this :
AATT CTTA ATCG
But it doesn't working for size of sequence which isn't divisible by 4.
For this : ATCGCTTAAAT
I obtain : AATACTTAATC
I do this, with this code :
1 2 3 4 5 6
|
size_t longueur_tab = (longueur/4 + (longueur%4 !=0)), temp = 0;
for (size_t i = 0 ; i < (longueur_tab/2) ; i++){
temp = tab[i];
tab[i] = tab[longueur_tab - i -1];
tab[longueur_tab - i - 1] = temp;
}
|
Note : longueur : is for the size of my sequence
In a second time, I want to obtain :
TAAATTCGCTA
But it's too difficult for me !
Thank you very much for your help and sorry for my english !!