/* 给你一个字符串 1a2b3c
把里面的数字给显示出来 i[]
把里面的字母转大写显示出来 ch[] */
#include <stdio.h>
#include <string.h>
int main()
{
char str[] = "0a1a2b3c9z";
int len = strlen(str);
int in[5];
char ch[5];
int i;
int j = 0;
int k = 0;
for (i = 0; i < len; i++)
{
if (str[i] >= 'a' && str[i] <= 'z')
ch[k++] = str[i] + 'A' - 'a';
else if (str[i] >= '0' && str[i] <= '9')
in[j++] = str[i];
}
for (i = 0; i < 5; i++)
printf("%c ", in[i]);
printf("\n");
for (i = 0; i < 5; i++)
printf("%c ", ch[i]);
printf("\n");
return 0;
}
运行结果: