1874 - C语言考试练习题_保留字母

通过次数

0

提交次数

0

时间限制 : 1 秒 内存限制 : 128 MB

编一个程序,输入一个字符串,将组成字符串的所有非英文字母的字符删除后输出。

题目输入

一个字符串,长度不超过80个字符

题目输出

删掉非英文字母后的字符串。

输入/输出样例

输入格式

abc123+xyz.5

输出格式

abcxyz

C++解答

#include<iostream>
#include<string>
#include<cctype>
using namespace std;
int main()
{
	string from,to;
	getline(cin,from);
	int len=from.size(),j=0;
	for (int i=0; i<len; i++)
		if (isalpha(from[i])) to+=from[i];
	cout<<to<<endl;
	return 0;
}