文章

40

粉丝

512

获赞

13

访问

354.8k

头像
注意cnt=5之后要清零
Ang VIP
P1557 北京邮电大学机试题
发布于2020年3月14日 14:03
阅读数 8.4k

#include<bits/stdc++.h>
using namespace std;

int main(){
    int N;
    cin>>N;
    while(N--){
        string str;
        cin>>str;
        int cnt=0;
        for(int i=0;i<str.size();i++){
            if(str[i]=='1'){
                cnt++;
            }else{
                cnt=0;
            }
            if(cnt==5){
                cnt = 0;
                str.erase(i+1,1);
            }
        }
        cout<<str<<endl;
    }
}

 

登录查看完整内容


登录后发布评论

暂无评论,来抢沙发