카타 7급 Complementary DNA

C[ | ]

#include <string.h>
char *dna_strand(const char *dna)
{
  char *res = strdup(dna);
  for (char *p=res; *p; p++) {
    switch (*p) {
    case 'A': *p = 'T'; break;
    case 'T': *p = 'A'; break;
    case 'C': *p = 'G'; break;
    case 'G': *p = 'C'; break;
    }
  }
  return res;
}
#include <stdlib.h>
char *dna_strand(const char *dna)
{
    char *res = calloc(strlen(dna)+1, sizeof(char));
    char *p = res;
    while(*dna) {
      switch( *dna ) {
      case 'A': *p++ = 'T'; break;
      case 'T': *p++ = 'A'; break;
      case 'C': *p++ = 'G'; break;
      case 'G': *p++ = 'C'; break;
      }
      dna++;
    }
    p = '\0';
    return res;
}
문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}