解题思路:对应位置进行比较
注意事项:
参考代码:
#include<iostream>
#include<string>
using namespace std;
int main()
{
double p;
cin>>p;
double correct;
string str1;
string str2;
cin>>str1;
cin>>str2;
for(unsigned int i=0;i<str1.length();i++)
{
//TODO
if(str1[i] == str2[i])
{
correct++;
}
}
double P = correct/str1.length()*1.0;
if(P>=p)
{
cout<<"yes";
}
else
cout<<"no";
}
0.0分
1 人评分
#include <iostream> #include <cstring> using namespace std; int main() { char a[100], b[100]; double x, len, mean = 0; cin >> x >> a >> b; len = strlen(a); for (int i = 0; i < len; i++) { if (a[i] == b[i]) mean++; } double y = mean / len * 1.0; if (y >= x) { cout << "yes" << endl; } else { cout << "no" << endl; } return 0; }这哪错了啊?