为什么无法识别换行啊!!会超时!求助!!
查看原帖
为什么无法识别换行啊!!会超时!求助!!
1084289
GMU_ZE_Homer楼主2023/11/16 15:14
#include <iostream>
#include <cstring>

using namespace std;
int main()
{
    int i,ans;string a,b[1000000];char c,d;
    while(c!='\n')
    {
        c = getchar();
        if(c>='a'&&c<='z') c=c-32;
			a = a + c;
            
    }
    i=0;
    int time=0;
    int times=0;
     while(d!='\n')
    {
        d = getchar();
        if(d>='a'&&d<='z') d=d-32;
        if (d == ' ') //空格则改变字符串下标
        {
            i++;
            continue;
        }
        else
		{
			b[i] = b[i] + d;
            if(b[i]==a) times++;
            if(time==0&&b[i]==a) 
            {
            time++;
            ans=i;
            }
		}
    }
    if(times>0)
    {
        cout<<times<<" "<<ans;
        return 0;
    }
    cout<<"-1";
    return 0;
}
2023/11/16 15:14
加载中...