0
点赞
收藏
分享

微信扫一扫

C. Detective Task

佛贝鲁先生 2022-05-06 阅读 109
c++算法
#include<iostream>
#include<string>
using namespace std;
int main(){
    int t=0;
    cin>>t;
    while(t--){
        string str;
        cin>>str;
        int len=str.size();
        if(len==1) cout<<"1\n";
        else if(str.find('0')==-1&&str.find('1')==-1) cout<<len<<endl;
        else{
            int s=0,n=len-1;
            if(str.find('0')!=-1) n=str.find('0');
            
            for(int i=n;i>=0;i--,s++){
                if(str[i]=='1'){
                    s++;
                    break;
                }
            }
            cout<<s<<endl;
        }
    }
    return 0;
}
举报

相关推荐

C. digitnum

C. Make Good

C. Manipulating History

C. Ilya and Matrix

C.开餐馆

C. Social Distance

C. Dolce Vita

0 条评论