zoukankan      html  css  js  c++  java
  • UVa1368/ZOJ3132 DNA Consensus String

    #include <stdio.h>
    #include <string.h>

    int main()
    {
        int a[4][1000]; // A/C/G/T在每列中出现的次数
        char c, x;
        char bas[4] = { 'A', 'C', 'G', 'T' };
        int T, m, n, i, j, k, dist;
        scanf("%d", &T);
        while (T--)
        {
            scanf("%d %d ", &m, &n);
            memset(a, 0, sizeof(a));
            for (i = 0; i < m; ++i)
            {
                for (j = 0; j < n; ++j)
                {
                    c = getchar();
                    if (c == 'A')
                        ++a[0][j];
                    else if (c == 'C')
                        ++a[1][j];
                    else if (c == 'G')
                        ++a[2][j];
                    else
                        ++a[3][j];
                }
                getchar();
            }

            dist = 0;
            for (j = 0; j < n; ++j)
            {
                k = -1;
                for (i = 0; i < 4; ++i)
                {
                    if (a[i][j] > k)
                    {
                        k = a[i][j];
                        x = bas[i];
                    }
                }
                for (i = 0; i < 4; ++i)
                {
                    if (bas[i] != x)
                        dist += a[i][j];
                }
                putchar(x);
            }
            printf(" %d ", dist);
        }

        return 0;
    }

  • 相关阅读:
    Web持久化存储Web SQL、Local Storage、Cookies(常用)
    浅谈TypeScript
    浅谈JavaScript、ES5、ES6
    AngularJS1.3一些技巧
    AngularJS学习总结
    poj-----Ultra-QuickSort(离散化+树状数组)
    HDUOJ---1241Oil Deposits(dfs)
    HDUOJ---携程员工运动会场地问题
    HDUOJ------2398Savings Account
    HDUOJ-----2399GPA
  • 原文地址:https://www.cnblogs.com/danny1221/p/4592719.html
Copyright © 2011-2022 走看看