Skip to content

Instantly share code, notes, and snippets.

@yfe404
Created November 25, 2013 20:42
Show Gist options
  • Save yfe404/7648533 to your computer and use it in GitHub Desktop.
Save yfe404/7648533 to your computer and use it in GitHub Desktop.
Counting DNA Nucleotides ==> http://rosalind.info/problems/dna/
#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