fork download
  1. #include <stdio.h>
  2. #include <string.h>
  3.  
  4. int main()
  5. {
  6. char buf[100], *name[] = {"Thymine", "Cytosine", "Adenine", "Guanine"}, sname[] = "tcag", *p;
  7. int i, cnt[4] = {0};
  8.  
  9. scanf("%s", buf);
  10. for (i = 0; buf[i]; ++i)
  11. {
  12. p = strchr(sname, buf[i]);
  13. if (p)++cnt[p - sname];
  14. }
  15. for (i = 0; i < 4; ++i)
  16. printf("%s (%c) : %d\n", name[i], sname[i], cnt[i]);
  17.  
  18. return 0;
  19. }
Success #stdin #stdout 0s 1792KB
stdin
tcaggtacatca
stdout
Thymine (t) : 3
Cytosine (c) : 3
Adenine (a) : 4
Guanine (g) : 2