Last active
June 24, 2016 10:04
-
-
Save Swarchal/795f8fd8b32221f5540cf460b7fc49b6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <string> | |
using namespace std; | |
// convert DNA to RNA | |
int main() | |
{ | |
string s; | |
// take DNA string as input from stdin | |
cin >> s; | |
char n; // current nucleotide | |
// loop through sequence, if T replace with U | |
for (int i=0; i<s.length(); i++) | |
{ | |
n = s[i]; | |
if (n == 'T') | |
{ | |
s[i] = 'U'; | |
} | |
} | |
// output to stdout | |
cout << s << endl; | |
return 0; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# include <iostream> | |
# include <string> | |
# include <algorithm> | |
using namespace std; | |
int main() | |
{ | |
string s; | |
cin >> s; // take input from console | |
replace(s.begin(), s.end(), 'T', 'U'); | |
cout << s << endl; // send ouput to console | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment