#include<iostream>
using namespace std;
int student,score = 0,point,anslen;
int main(){
cin>>anslen;
point = 100/anslen;
string standard,studentans;
cin>>standard;
cin>>student;
for(int i = 0;i<student;i++){
score = 0;
cin>>studentans;
for(int j = 0;j<anslen||j<=studentans.length();j++){
if(studentans[j] == standard[j])
score += point;
}
cout<<score<<'\n';
}
}
My code:
不確定哪裡不對
#include
using namespace std;
int student,score = 0,point,anslen;
int main(){
cin>>anslen;
point = 100/anslen;
string standard,studentans;
cin>>standard;
cin>>student;
for(int i = 0;i<student;i++){
score = 0;
cin>>studentans;
for(int j = 0;j<anslen||j<=studentans.length();j++){
if(studentans[j] == standard[j])
score += point;
}
cout<<score<<'\n';
}
}
My code:
不確定哪裡不對
我也是50%....
#include<bits/stdc++.h>
using namespace std;
int main(){
int a,e,d,g;
cin>>a;
e=100/a;
char b[a],c[a];
cin>>b;
cin>>d;
while(d--){
g=0;
cin>>c;
for(int f=0;f<a;f++){
if(b[f]==c[f])
g=g+e;
}
cout<<g<<endl;
}
}