hlep!

P1042 [NOIP2003 普及组] 乒乓球

guomu @ 2024-10-05 16:26:18

#include <bits/stdc++.h>
using namespace std;
int l,r,m,n,a;
string s,t;
int main (){
    while(cin>>t){
        s+=t;
    }
    n=s.size();
    for(int i=0;i<n;i++){
        if(s[i]=='W') l++;
        if(s[i]=='L') r++;
        if((l>=11||r>=11)&&abs(l-r)>=2){
            cout<<l<<":"<<r<<"\n";
            l=0;
            r=0;
        }
        if(s[i]=='E'){
            break;
            cout<<l<<":"<<r<<"\n";
        }
    }
    cout<<endl;
    for(int i=0;i<n;i++){
        if(s[i]=='W') l++;
        if(s[i]=='L') r++;
        if((l>=21||r>=21)&&abs(l-r)>=2){
            cout<<l<<":"<<r<<"\n";
            l=0;
            r=0;
        }
        if(s[i]=='E'){
            break;
            cout<<l<<":"<<r<<"\n";
        }
    }
    return 0;
}

为何不对?


by KellyH @ 2024-10-05 16:30:09

我来康康


by untitled_cpp @ 2024-10-05 16:30:16

@guomu 《hlep》


by KellyH @ 2024-10-05 16:34:26

string是字符串,一下子会输入好几个字符呀 你想想,字符串一输就是一大串,所以你得用char呀
并且字符串也不能用单引号,肯定就报错了


by KellyH @ 2024-10-05 16:35:55

@guomu 懂了吗
互关吗( ̄︶ ̄)


by KellyH @ 2024-10-05 16:38:18

好像你已经关注我了,谢谢哈


by guomu @ 2024-10-05 16:40:49

求大佬康康


by guomu @ 2024-10-05 16:41:54

没报错


|