0分求助
查看原帖
0分求助
1228886
skyx楼主2024/5/18 20:46

在程序中,为啥无论输入什么,运行到 if(isupper(b[j])) f++会结束(跳出)?

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

bool pan(char e)
{
    if(e=='!' || e=='@' || e=='#' || e=='$') 
        return 1;
    else 
        return 0;
}

int main()
{
    char a[120];
    char b[120];
    int m=0;
    cin.getline(a,120);
    for(int i=0; i<strlen(a)-1; i++)
    {
        if(a[i]!=',')
        {
            b[i]=a[i];
        }
        else
        {
            bool flag=1;
            int f=0;
            int Special=0;
            m=strlen(b);
            if(m<6 || m>12) 
            {
                flag=false;
                memset(b, 0, sizeof(b)); 
                continue;//要求2 
            } 
            for(int j=0; j<strlen(b)-1; j++)
            {
                if(pan(b[j])) 
                    Special++;
                if(isdigit(b[j])) 
                    f++;
                if(isupper(b[j])) 
                    f++;
                if(islower(b[j])) 
                    f++;
            }
            if(flag || f<2 || Special==0) 
            {
                memset(b, 0, sizeof(b)); 
                continue;
            }
            else 
            {
                cout << b << endl; 
            }
            memset(b, 0, sizeof(b)); 
        }}
    return 0;
}

2024/5/18 20:46
加载中...