例如:
输入:Thdad29#@12aH;77
输出:
ThdadaH
291277
#@;
#include <stdio.h>
#include <string.h>
int main(){
char a[100];
char cha[100]={'\0'};
char other[100]={'\0'};
char num[100]={'\0'};
int ncha=0,not=0,nnum=0;
gets(a);
int n=strlen(a);
for(int i=0;i<n;i++)
{
if(a[i]>='A'&&a[i]<='Z'||a[i]>='a'&&a[i]<='z')
{ cha[ncha]=a[i];
ncha++;
}
else if(a[i]>='0'&&a[i]<='9')
{ num[nnum]=a[i];
nnum++;
}
else { other[not]=a[i];
not++;
}
}
puts(cha);
puts(num);
puts(other);
}
运行结果: