大佬帮忙看看哪错了吧,本地输出全是0!!!

UVA1585 Score

```cpp #include<bits/stdc++.h> using namespace std; int main(){ int n; cin>>n; for(int i=1;i<=n;i++){ string s; int ans=0,t=0; cin>>s; int len=s.size(); for(int j=0;j<len;j++){ if(s[j]=='O'){ ans=(ans+1); t=t+ans; } if(s[j]=='X'){ ans=0; t=t+ans; } } cout<<t<<endl; } return 0; } ```
by Withershine @ 2023-11-08 17:24:05


@[ouiostream](/user/557069)
by Withershine @ 2023-11-08 17:24:20


@[Withershine](/user/461407) ~~你就不跟同学的弟弟说说错在哪?~~
by Soul_Love @ 2023-11-08 17:27:41


谢了。 我哥......
by ouiostream @ 2023-11-08 17:27:49


@[ouiostream](/user/557069) 1,如果想把每段字符串单独处理,就不应该先读入全部字符串,而是读一行处理并输出一行。 2,每次 t 要清空。 3,认真读题,每次 ans 更新后 t 也要更新。
by Withershine @ 2023-11-08 17:29:43


@[Withershine](/user/461407) @[Soul_Love](/user/110009) 知道了 这水题我其实还没看完就开做了
by ouiostream @ 2023-11-09 12:24:18


刷水题没刷过
by ouiostream @ 2023-11-09 12:40:30


|