Created
November 25, 2013 20:42
-
-
Save yfe404/7648533 to your computer and use it in GitHub Desktop.
Counting DNA Nucleotides
==> http://rosalind.info/problems/dna/
This file contains 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 <stdio.h> | |
int main(int argc, char * argv[]) | |
{ | |
if(argc < 2){ | |
fprintf(stderr, "Missing argument !\n"); | |
return -1; | |
} | |
if(argc > 2){ | |
fprintf(stderr, "Too many arguments\n"); | |
return -1; | |
} | |
unsigned i; | |
unsigned a=0, t=0, c=0, g=0; | |
for(i = 0; argv[1][i]!='\0'; ++i) | |
{ | |
switch(argv[1][i]) | |
{ | |
case 'A': ++a; break; | |
case 'T': ++t; break; | |
case 'C': ++c; break; | |
case 'G': ++g; break; | |
default : fprintf(stderr,"String given contains unknown caracters\n"); return -1; | |
} | |
} | |
printf("A : %d; T : %d; C : %d; G : %d\n", a, t, c, g); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment