C语言实验——保留字母
Time Limit: 1000MS Memory Limit: 65536KB
Problem Description
编一个程序,输入一个字符串,将组成字符串的所有非英文字母的字符删除后输出。
Input
一个字符串,长度不超过80个字符。
Output
删掉非英文字母后的字符串。
Example Input
abc123+xyz.5
Example Output
abcxyz
Hint
Author
ZJGSU
参考代码
#include<stdio.h>
#include<string.h>
int main()
{
char a[81];
gets(a);
int i;
for(i = 0; i < strlen(a); i++)
{
if(a[i] >= 'a' && a[i] <= 'z' || a[i] >= 'A' && a[i] <= 'Z')
printf("%c",a[i]);
}
return 0;
}