来自蒟蒻的求救,不是很会字符串

P1200 [USACO1.1] 你的飞碟在这儿 Your Ride Is Here

@[NGDZJ](/space/show?uid=174129) 你看一下我的 ```cpp #include <bits/stdc++.h> using namespace std; int main() { long long a = 1, b = 1; string str; getline(cin, str); for (auto x : str) a *= (x - '@'), a %= 47; getline(cin, str); for (auto x : str) b *= (x - '@'), b %= 47; if (a == b) cout << "GO" << endl; else cout << "STAY" << endl; return 0; } ```
by andyli @ 2019-02-04 00:27:56


@[NGDZJ](/space/show?uid=174129) `i=1;`后面加一个`getchar();`
by andyli @ 2019-02-04 00:29:22


空格是吗?
by 第二小题 @ 2019-02-04 00:33:08


我的ans和ans1怎么都是1啊!!!!!!!!!!!!!!
by 第二小题 @ 2019-02-04 00:35:07


@[NGDZJ](/space/show?uid=174129) 建议使用`getline` ```cpp getline(cin,str); ```
by Jelly_Goat @ 2019-02-04 00:43:51


哦!
by 第二小题 @ 2019-02-04 00:50:19


~~打个样例?~~ ~~给你一个详细的解释?~~ 那个输入换成逗号表达式会~~更加方便~~: ```cpp while (temp=getchar(),temp!='\n') { a[i++]=temp; }i=1; while (temp=getchar(),temp!='\n') { b[i++]=temp; } /*下面应该没多大毛病*/ ``` 您的输入有可能所有的读入都变成了一个玄学字符... @[andyli](/space/show?uid=84282) 您的`auto x:str`对人家太不友好了...
by Jelly_Goat @ 2019-02-04 00:53:39


@[NGDZJ](/space/show?uid=174129)
by Jelly_Goat @ 2019-02-04 00:54:18


巧了,我的第一篇博客是这个题:[传送](https://www.luogu.org/blog/jelly123/solution-p1200)
by Jelly_Goat @ 2019-02-04 00:59:10


emmmm,~~应该是读入字符串时把回车也读进去了~~
by MakiseVon @ 2019-02-04 01:23:43


| 下一页