jeudi 26 août 2021

for(char d:s) what does it mean? [duplicate]

I watched how williamlin solving cses problemset. In third problem he had this code:

`int main(){
string s;
cin>>s;
int ans=1,c=0;
char l='A';
for(char d:s){ // I don't understand this
    if(d==1){
        ++c;
        ans = max(c,ans);
    }
    else{
        l=d;
        c=1;
    }
}
cout << ans;

}`

I don't understand what does it mean for(char d:s) Pleas describe (.

Aucun commentaire:

Enregistrer un commentaire