请大佬看看为啥不对嘞
查看原帖
请大佬看看为啥不对嘞
1058418
SD2441856574楼主2023/10/30 19:46
#include <iostream>

using namespace std;

int main()
{
    string str;
    getline(cin, str);

    char s[100];
    int a = 0;
    if(str[str.length() - 1] == 'g' && str[str.length() - 2] == 'n' && str[str.length() - 3] == 'i')
    {
        for(int i = 0; i < str.length() - 3; i++)
        {
            s[i] = str[i];
        }
        a += 1;
    }

    if(str[str.length() - 1] == 'r' && str[str.length() - 2] == 'e' )
    {
        for(int i = 0; i < str.length() - 2; i++)
        {
            s[i] = str[i];
        }
        a += 1;
    }

    if(str[str.length() - 1] == 'y' && str[str.length() - 2] == 'l' )
    {
        for(int i = 0; i < str.length() - 2; i++)
        {
            s[i] = str[i];
        }
        a += 1;
    }
    if( a == 0)
    {
        for(int i = 0; i <= str.length() - 1; i ++)
        {
            s[i] = str[i];
        }
    }
    cout << s << endl;

    return 0;

}
2023/10/30 19:46
加载中...