萌新求助:本地无报错,提交多次编译失败 /tmp/compiler_pqwjmj96/src: 在函数‘int main()’中: /tmp/compiler_pqwjmj96/src:14:3: 错误:‘gets’ was not declared in this scope; did you mean ‘fgets’? 14 | gets(a); | ^~~~ | fgets /tmp/compiler_pqwjmj96/src:24:3: 错误:‘gets’ was not declared in this scope; did you mean ‘fgets’? 24 | gets(a); | ^~~~ | fgets
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
char a[10005],fanwen[1002][10002],shuru[1002][10002];
int k[10005];
string b;
int main()
{
int l,shu1=0,shu2=0,fan[1005];
double KMP,time,shu=0;
while(true)
{
gets(a);
b=a;
if(b=="EOF") break;
shu1++;
fan[shu1]=strlen(a);
for(int i=1;i<=fan[shu1];i++)
fanwen[shu1][i]=a[i-1];
}
while(true)
{
gets(a);
b=a;
if(b=="EOF") break;
shu2++;
k[shu2]=0;
l=strlen(a);
for(int i=1;i<=l;i++)
{
if(a[i-1]=='<'&&k[shu2]>=1)
{
k[shu2]--;
continue;
}
k[shu2]++;
shuru[shu2][k[shu2]]=a[i-1];
}
}
cin>>time;
for(int i=1;i<=shu1;i++)
{
for(int j=1;j<=fan[i];j++)
{
if(fanwen[i][j]==shuru[i][j]) shu++;
}
}
KMP=shu/(time/60);
int x=(int)KMP;
if(KMP-x<0.5) cout<<x;
else cout<<x+1;
return 0;
}