UVA-3.7-DNA序列-1368
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
struct com
{
char s;
int book;
};
int main()
{
int N;
scanf("%d",&N);
struct com mark[5];
mark[1].s='A';
mark[2].s='C';
mark[3].s='G';
mark[4].s='T';
while(N--)
{
int m,n;
scanf("%d%d",&m,&n);
char space;
space=getchar();
char str[100][1010];
int i,j;
mark[1].book=0;
mark[2].book=0;
mark[3].book=0;
mark[4].book=0;
for(i=1;i<=m;i++)
{
gets(str[i]);
}
int sum=0;
for(j=0;j<n;j++)
{
for(i=1;i<=m;i++)
{
if(str[i][j]=='A')
mark[1].book++;
if(str[i][j]=='C')
mark[2].book++;
if(str[i][j]=='G')
mark[3].book++;
if(str[i][j]=='T')
mark[4].book++;
}
int max;
for(i=1;i<=4;i++)
{
if(i==1)
max=mark[i].book;
else
{
if(max<mark[i].book)
max=mark[i].book;
}
}
//int sum=0;
int mark1=1;
for(i=1;i<=4;i++)
{
if(mark[i].book==max)
{
if(mark1==1)
{
printf("%c",mark[i].s);
mark1=0;
}
else
sum+=mark[i].book;
}
else
sum+=mark[i].book;
}
//printf("\n%d\n",sum);
mark[1].book=0;
mark[2].book=0;
mark[3].book=0;
mark[4].book=0;
}
printf("\n%d\n",sum);
}
}