求助大佬
  • 板块P5587 打字练习
  • 楼主wmyQAQ
  • 当前回复6
  • 已保存回复6
  • 发布时间2023/8/14 21:10
  • 上次更新2023/11/3 03:46:15
查看原帖
求助大佬
134184
wmyQAQ楼主2023/8/14 21:10

萌新求助:本地无报错,提交多次编译失败 /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;
}
2023/8/14 21:10
加载中...