萌新求助,getline出了什么问题……

P2264 情书

```cpp #include <iostream> #include <cstring> #include <string> using namespace std; int n,ans=0; string dictionary[100],text,word="",N; bool used[100]={}; string strlwr(string str) { for(int i=0;i<=str.length()-1;++i) { str[i]=tolower(str[i]); } return str; } int main() { cin>>n; for(int i=0;i<=n-1;++i) { cin>>dictionary[i]; dictionary[i]=strlwr(dictionary[i]); } getline(cin,text); text=strlwr(text); for(int i=0;i<=text.length()-1;++i) { if(text[i]>=97&&text[i]<=122) { word+=text[i]; } else if(text[i]==' '||text[i]==','||text[i]=='.') { if(text[i-1]>=97&&text[i-1]<=122) { for(int j=0;j<=n-1;++j) { if(word==dictionary[j]) { if(used[j]==0) { ++ans; word=""; used[j]=1; break; } else { break; } } } } if(text[i]=='.') { memset(used,0,sizeof(used)); } } } cout<<ans<<endl; } ```
by BurningEnderDragon @ 2020-10-29 15:29:00


(话说我名字缩写就是CYY……)
by BurningEnderDragon @ 2020-10-29 15:29:39


@[BurningEnderDragon](/user/386876) 为什么不用$char$数组呢?
by wu_wowo @ 2020-10-29 21:13:08


[我找到问题了QWQ](https://blog.csdn.net/qq_40725780/article/details/81032700)
by BurningEnderDragon @ 2020-10-29 21:24:49


|