zoukankan      html  css  js  c++  java
  • uva368 水题 关于memset初始化的位置

    #include<algorithm>
    #include <iostream>
    #include <sstream>
    #include <cstdlib>
    #include <cstring>
    #include <cstdio>
    #include <vector>
    #include <ctime>
    #include <set>
    #include <map>

    using namespace std;
    int pd[100],sss[4]={0,2,6,19};
    char dna[55][1005],ss[]="ACGT",s[1005];
    int main(){
    memset(s,0,sizeof(s)); //疯狂WA,奇怪的是样例也能过
    int n,m,t,q;scanf("%d",&t);
    while(t--){
    //memset(s,0,sizeof(s));//AC、
    scanf("%d%d",&n,&m);int sum = 0;
    for(int i = 1; i <= n; i++)scanf("%s",dna[i]);

    for(int j = 0; j < m; j++)
    {
    memset(pd,0,sizeof(pd));
    for(int i = 1; i <= n; i++)pd[dna[i][j]]++;

    int max = 0,x;
    for(int k = 0; k < 4; k++)
    if(pd[ss[k]] > max)
    max = pd[ss[k]],s[j] = ss[k];
    sum += max;
    }puts(s);
    printf("%d ",n*m-sum);
    }return 0;
    }

    /*
    Sample Input
    3
    5 8
    TATGATAC
    TAAGCTAC
    AAAGATCC
    TGAGATAC
    TAAGATGT
    4 10
    ACGTACGTAC
    CCGTACGTAG
    GCGTACGTAT
    TCGTACGTAA
    6 10
    ATGTTACCAT
    AAGTTACGAT
    AACAAAGCAA
    AAGTTACCTT
    AAGTTACCAA
    TACTTACCAA
    Sample Output
    TAAGATAC
    7
    ACGTACGTAA
    6
    AAGTTACCAA
    12

    #include<bits/stdc++.h>

    char dna[510][1010],s[1100];
    int pos[4]={0,2,6,19},n,m;
    int main(){
    int t,pd[26];
    scanf("%d",&t);
    while(t--){
    memset(s,0,sizeof(s));
    scanf("%d%d",&m,&n);
    for(int i = 0; i < m; i++)scanf("%s",dna[i]);
    int sum = 0;
    for(int j = 0; j < n; j++){
    memset(pd,0,sizeof(pd));
    for(int i = 0; i < m; i++ )
    pd[dna[i][j]-'A']++;
    int max = 0;
    for(int i = 0; i < 4; i++)
    if(max < pd[pos[i]])
    max = pd[pos[i]],s[j] = pos[i]+'A';
    sum += max;
    }
    puts(s);
    printf("%d ",n*m-sum );
    }
    return 0;
    }*/

  • 相关阅读:
    模拟链表
    解密回文——栈
    解密QQ——队列
    排序算法的实现与比较
    2016年第七届蓝桥杯C/C++B组省赛题目解析
    记账类问题汇总
    斐波那契数列题型汇总
    MFC绘图小实验(1)
    MFC绘图基础——上机操作步骤
    求 pi 的近似值题型汇总
  • 原文地址:https://www.cnblogs.com/163467wyj/p/9825376.html
Copyright © 2011-2022 走看看