求助!80分!
查看原帖
求助!80分!
355559
FutureThx楼主2020/7/17 11:14

测试点 # 3 和 # 5 WA了,求大佬指错

#include <iostream>
#include <cstring>
#include <cmath>
using namespace std;
double letter_number = 0;
void First_Clue(string a){
    int len = a.size();
    for (int i = 0;i < len;i++){
        if((a[i] >= 97 && a[i] <= 122) || (a[i] >= 65 && a[i] <= 90)){
            cout << ".";
            letter_number++;
        }
        else
            cout << a[i];
    }
    cout << endl;
}
void Second_Clue(string a){
    double n = letter_number / 3.000;
    int t = round(n),len = a.size();
    for (int i = 0;i < len;i++){
        if((a[i] >= 97 && a[i] <= 122) || (a[i] >= 65 && a[i] <= 90)){
            if(t > 0){
                t--;
                cout << a[i];
            }
            else 
                cout << ".";
        }
        else
            cout << a[i];
    }
    cout << endl;
}
void Third_Clue(string a){
    int find[123];
    find['a'] = 1;
    find['A'] = 1;
    find['e'] = 1;
    find['E'] = 1;
    find['i'] = 1;
    find['I'] = 1;
    find['o'] = 1;
    find['O'] = 1;
    find['u'] = 1;
    find['U'] = 1;
    double n = letter_number / 3.000;
    int t = round(n),t_2 = t,len = a.size(),vowels = 0;
    for (int i = 0;i < len;i++){
        if((a[i] >= 97 && a[i] <= 122) || (a[i] >= 65 && a[i] <= 90)){
            if(t_2 > 0)
                t_2--;
            else 
                if(find[a[i]] == 1)
                    vowels++;
        }
        else
          t+=0;
    }
    if(vowels == 0){
        n = 2.000 * letter_number / 3.000;
        int t = round(n),len = a.size();
        for (int i = 0;i < len;i++){
            if((a[i] >= 97 && a[i] <= 122) || (a[i] >= 65 && a[i] <= 90)){
                if(t > 0){
                    t--;
                    cout << a[i];
                }
                else 
                    cout << ".";
            }
            else
                cout << a[i];
        }
        cout << endl;
    }
    else{
        double n = letter_number / 3.000;
        int t = round(n),len = a.size();
        for (int i = 0;i < len;i++){
            if((a[i] >= 97 && a[i] <= 122) || (a[i] >= 65 && a[i] <= 90)){
                if(t > 0){
                    t--;
                    cout << a[i];
                }
                else {
                    if(find[a[i]] == 1)
                       cout << a[i];
                    else
                       cout << ".";
                }
            }
            else
                cout << a[i];
        }
        cout << endl;
    }
}
int main()
{
    string a;
    getline(cin,a);
    First_Clue(a);
    Second_Clue(a);
    Third_Clue(a);
    return 0;
}
2020/7/17 11:14
加载中...