求助。为何只输出一个?

B3843 [GESP202306 三级] 密码合规

future666 @ 2024-07-22 13:12:04

#include <bits/stdc++.h>
using namespace std;
int main(){
    string c;
    int a=1,b=0,ans;
    cin>>c;
    for(int i=0;;i++){
        b++;
        if((c[i]-'a'>=0&&c[i]-'a'<=25)||(c[i]-'A'>=0&&c[i]-'A'<=25)||(c[i]-'0'<=9&&c[i]-'0'>=0)||c[i]=='!'||c[i]=='#'||c[i]=='$'||c[i]=='@') ans=1;
        else if(c[i]==','){
            if(i>=6&&i<=12&&a==1){
                for(int j=0;j<b-1;j++) cout<<c[j];
                cout<<endl;
                b=0;
            }
        }
        else a=0;
    }
    return 0;
}

by ccccccyd @ 2024-07-22 13:23:53

没看题目

但:

5 14 [Warning] variable 'ans' set but not used [-Wunused-but-set-variable]

by future666 @ 2024-07-26 11:25:01

@ccccccyd 什么意思


|