60pts再次求助qwq
查看原帖
60pts再次求助qwq
183603
SUNCHAOYI楼主2020/5/1 14:03

哪里有问题呢?

#include <iostream>
#include <string>
#define MAX 1005
using namespace std;
int main()
{
	string x,stra[MAX],strb[MAX];
	double n;int k = 0,numa = 0,numb = 0,ans = 0;
	while(getline(cin,x))
	{
		if(x == "EOF") break;
		++numa;stra[numa] = "";
		for(register int i = max(0,(int)x.size() - 1);i >= 0;--i)
		{
			if(x[i] == '<') k++;
			else if(k > 0) k--;
			else stra[numa] += x[i];
		}
	} 
	k = 0;
	while(getline(cin,x))
	{
		if(x == "EOF") break;
		++numb;strb[numb] = "";
		for(register int i = max(0,(int)x.size() - 1);i >= 0;--i)
		{
			if(x[i] == '<') k++;
			else if(k > 0) k--;
			else strb[numb] += x[i];
		}
	} 
	for(register int i = 1;i <= min(numa,numb);++i)
		for(register int j1 = max(0,(int)stra[i].size() - 1),j2 = max(0,(int)strb[i].size() - 1);j1 >= 0,j2 >= 0;--j1,--j2)
			if(stra[i][j1] == strb[i][j2]) ans++;
	cin>>n;
	cout<<(int)(ans / n * 60 + 0.5)<<endl;
	return 0;
}
2020/5/1 14:03
加载中...