对比两条DNA的相同率
[C++] 纯文本查看 复制代码 #include<cstdio>
#include<iostream>
using namespace std;
int main()
{
int len,tot=0;
double x;
char s1[501],s2[501];
cin>>x>>s1>>s2; //输入s1和s2的某一条基因序列
len=strlen(s1); //求得s1共有多少碱基
for (int i=0;i<len;i++) //循环看是否相同
if(s1[i]==s2[i]) //如果相同就+1
tot++;
if ((double)tot/len>=x)//计算相同比例
cout<<"yes"<<endl;
else
cout<<"no"<<endl;
return 0;
}
|