In molecular biology the “”alphabet”” of genes consists of four chemicals (called nucleotides) represented by the letters A C G T. A triad is a sequence of three nucleotides (for example AGA) and specifies an amino acid, a building block for proteins. A gene consists of a very, very long sequence of A-C-G-T combinations. Assume the input consists of a long sequence of A-C-G-T letters representing a gene. Write the code necessary to skip over the first 7 letters and then read the next 4 triads, printing each out on its own line.

LANGUAGE: C++

CHALLENGE:

In molecular biology the “alphabet” of genes consists of four chemicals (called nucleotides) represented by the letters A C G T. A triad is a sequence of three nucleotides (for example AGA) and specifies an amino acid, a building block for proteins. A gene consists of a very, very long sequence of A-C-G-T combinations. Assume the input consists of a long sequence of A-C-G-T letters representing a gene. Write the code necessary to skip over the first 7 letters and then read the next 4 triads, printing each out on its own line.

SOLUTION:



char acid[4];
cin.get(acid, 7);
cin.ignore();

for (int i=0; i<4; i++){
    cin.get(acid, 4);
    for (int j=0; j<3; j++){
        cout << acid[j];
    }
    cout << "\n";
}