#include
using namespace std;
//判断是字母还是数字、数组A、个数、统计字符数组、统计字符个数、统计数字数组、统计数字个数
int JudgeAndOutput(char A[], int m, char OutPutChar[], int &ChCount, char OutPutNumber[],int &NumCount)
{
ChCount = 0, NumCount = 0;
for (int i = 0; i < m; i++)
{
if (A[i] >= 'A'&&A[i] <= 'z'){
OutPutChar[ChCount] = A[i];
ChCount++;
}
else if (A[i] >= '0'&&A[i] <= '9')
{
OutPutNumber[NumCount] = A[i];
NumCount++;
}
}
//输出字符
for (int i = 0; i < ChCount; i++)
cout << OutPutChar[i];
cout << endl;
//输出数字
for (int i = NumCount - 1; i >= 0; i--)
cout << OutPutNumber[i];
cout << endl;
return 0;
}
int main()
{
char A[100] = { 'A', 'a', 'Z', 'z', '2', 'h', 'i', '5', '4', 'g', 'G', '3', 'D', '3', '2', 'K', 'L', '1', '0' };
char OutPutChar[100], OutPutNumber[100];
int ChCount, NumCount;
JudgeAndOutput(A, 19, OutPutChar, ChCount, OutPutNumber, NumCount);
return 0;
}
输入序列{ 'A', 'a', 'Z', 'z', '2', 'h', 'i', '5', '4', 'g', 'G', '3', 'D', '3', '2', 'K', 'L', '1', '0' };
AaZzhigGDKL
01233452
请按任意键继续. . .