Created
June 17, 2016 12:26
-
-
Save Swarchal/0c8a06a2ada74e107b6cd560a87b80bf 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; | |
int main() | |
{ | |
//define variable s as DNA string | |
string s; | |
// get input from stdin | |
cin >> s; | |
// define counts of nucleotides | |
int a=0, c=0, g=0, t=0; | |
// define n as current nucleotide | |
char n; | |
// loop through elements of DNA string | |
for (int i=0; i<s.length(); ++i) | |
{ | |
n = s[i]; | |
if (n == 'A') | |
{ | |
a++; | |
} | |
if (n == 'C') | |
{ | |
c++; // wahey | |
} | |
if (n == 'G') | |
{ | |
g++; | |
} | |
if (n == 'T') | |
{ | |
t++; | |
} | |
} | |
// output to stdout | |
cout << a <<" "<< c <<" "<< g <<" "<< t << endl; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment