DNA Consensus String UVA - 1368
来源:互联网 发布:单词背诵软件 编辑:程序博客网 时间:2024/05/16 03:33
开始的时候,我以为从给出的几个DNA序列之中找出距离最小的DNA序列。一直做也都不对,后来数了一下发现第一个样例的结果确实是10而不是7,那就排除了代码正确性的问题,之后又看了一遍样例,发现第一个样例结果的最短距离DNA序列并不在给出的几个DNA序列之中,恍然大悟。
#include <stdio.h>#include <string.h>#define maxn 1010char str[maxn][maxn];char res[maxn];int cof[maxn];int main(void){ int m; scanf("%d", &m); while(m--){ int r, len; scanf("%d%d", &r, &len); int i, j; for(i = 0; i < r; i++) scanf("%s", str[i]); for(j = 0; j < len; j++){ memset(cof, 0, sizeof(cof)); for(i = 0; i < r; i++){ if(str[i][j] == 'A') cof[1]++; else if(str[i][j] == 'C') cof[2]++; else if(str[i][j] == 'G') cof[3]++; else if(str[i][j] == 'T') cof[4]++; } int M = 1; for(i = 2; i <= 4; i++){ if(cof[i] > cof[M]) M = i; }//ACGT在整数数组中的默认的排序解决字典序问题 if(M == 1) res[j] = 'A'; else if(M == 2) res[j] = 'C'; else if(M == 3) res[j] = 'G'; else if(M == 4) res[j] = 'T'; } res[len] = '\0'; int num = 0; for(i = 0; i < r; i++){ for(j = 0; j < len; j++){ if(str[i][j] != res[j]) num ++; } } printf("%s\n", res); printf("%d\n", num); } return 0;}
0 0
- UVA 1368 - DNA Consensus String
- uva 1368 DNA Consensus String
- Uva-1368-DNA Consensus String
- UVa 1368 DNA Consensus String
- UVA 1368 DNA Consensus String
- UVA 1368 DNA Consensus String
- UVa:1368 DNA Consensus String
- uva 1368 - DNA Consensus String
- UVa 1368 - DNA Consensus String
- UVa 1368 - DNA Consensus String
- UVa 1368 DNA Consensus String
- UVa 1368 - DNA Consensus String
- UVA - 1368 DNA Consensus String
- UVa 1368DNA Consensus String
- UVa 1368 - DNA Consensus String
- Uva 1368 DNA Consensus String
- 【Uva 1368】 DNA Consensus String
- UVa-1368 - DNA Consensus String
- ps导出选定切片
- 【Stanford CNN课程笔记】5. 神经网络解读1 几种常见的激活函数
- python
- 《出入库管理系统》软件主页与FAQ
- openGPS.cn - 关于手机号定位方面的个人理解
- DNA Consensus String UVA - 1368
- 神盾局特工的背景知识 SHIELD的等级制度
- LCS算法
- linux驱动-映射进程空间
- 20170212am htm
- salesforce 零基础学习(六十四)页面初始化时实现DML操作
- BZOJ3091: 城市旅行
- 新年开工项目经理要做的几件事
- POJ3254:Corn Fields