中英文拼音形式的转换

已知一个掺杂了多个数字字符的中文名拼音,去掉所有数字字符之后,形式为 “名” + 空格 + “姓”; 并且名和姓的首字母大写,其它小写,要求输出 姓名 全拼,且全为小写。(后附详细样例说明)
【输入形式】

一个字符串, 长度小于100,含一个空格,如 3N32a4ns234ha89n0 Z23hon4g66
【输出形式】

去掉字符串中的所有数字字符,形成形式为 “名” + 空格 + “姓”的中文名之后,再转换为全为小写的姓名全拼,,如 zhongnanshan

【样例输入】

3N32a4ns234ha89n0 Z23hon4g66
【样例输出】

zhongnanshan


#include <iostream>
#include <string>
#include <algorithm>
#include <sstream>
#include <vector>
using namespace std;
int main()
{
    vector<string> res;
    string str;
    getline(cin, str);
    string::iterator it = str.begin();
    while (it != str.end())
    {
        if ((*it >= '0') && (*it <= '9'))
        {
            it = str.erase(it);
        }
        else
        { // 必须加else
            it++;
        }
    }
    transform(str.begin(), str.end(), str.begin(), ::tolower);
    stringstream input(str);
    string result;
    while (input >> result)
        res.push_back(result);
    //输出res
    for (int i = 1; i >= 0; i--)
    {
        cout << res[i];
    }
    return 0;
}


#include<stdio.h>
#include<string.h>
/*
* 3N32a4ns234ha89n0 Z23hon4g66
*/
int main()
{
    char strM[100] = { 0 };
    char strX[100] = { 0 };
    char resM[100] = { 0 }; 
    char resX[100] = { 0 };
    scanf("%s%s",&strM,&strX);
    int i = 0, j = 0, flag = 0;
    while (strM[i]!='\0')
    {
        if (strM[i]>='A'&&strM[i]<='Z')
        {
                j = 0;
                flag = 0;
                resM[j]= strM[i] + 32;
        }
        if (strM[i] >= 'a' && strM[i] <= 'z')
        {
                j++;
                resM[j] = strM[i];
        }
        i++;
    }
    i = 0;
    while (strX[i] != '\0')
    {
        if (strX[i] >= 'A' && strX[i] <= 'Z')
        {
            j = 0;
            flag = 0;
            resX[j] = strX[i] + 32;
        }
        if (strX[i] >= 'a' && strX[i] <= 'z')
        {
            j++;
            resX[j] = strX[i];
        }
        i++;
    }
    printf("%s%s",resX,resM);
    return 0;
}