求助,没有输出,是哪里出了问题
查看原帖
求助,没有输出,是哪里出了问题
1511991
lingerpetals楼主2024/11/13 23:08
#include<iostream>
#include<string>
using namespace std;

int main()
{
	string match;
	string word;
	string s[1000000];
	int len = 0;
	int count = 0;
	int minindex = -1;
	cin>>match;
	for(int i = 0; i < match.size(); i++)
	{
		match[i] = toupper(match[i]);
	}
	while(cin>>word)
	{
		for(int i = 0; i < word.size(); i++)
		{
			word[i] = toupper(word[i]);
		}
		s[len] = word;
		++len;
	}
	for(int i = 0; i < len; i++)
	{
		if(match == s[i])
		{
			count++;
			if(minindex == -1)
			{
				minindex = i;
			}
		}
	}
	if(count == 0)
	{
		cout<<"-1"<<endl;
	}
	else
	{
		cout<<count<<" "<<minindex<<endl;
	}
	return 0;
}
2024/11/13 23:08
加载中...