描述
在现在的各种互联网应用中,在一段文字中使用'@'字符来提起一名用户是流行的做法。
例如:
"@littleho submitted his code 30 times before he got passed the system test."
其中littleho就是一个用户名。我们规定在一段文字中,'@'字符之后一段连续的、非空的大小写英文字母组成的字符串被视为提起的用户名。
给定一段文字,请你输出其中所有提到的用户名。
输入
一行文本,只包含大小写字母、标点符号和空格。长度不超过800。
输出
按文本中的顺序输出所有提到的用户名,之间用一个空格隔开。重复提到的相同用户名也重复输出。
样例输入
@abc:@@,@littleho's code is so confusing. @abc.
样例输出
abc littleho abc
考字符串处理,没啥难度,注意格式
#include <vector>
#include <stack>
#include <string>
#include <cstring>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <map>
#include <queue>
#define _for(i,a,b) for(int i=a;i<b;i++)
#define _unfor(i,a,b) for(int i=a;i>=b;i--)
#define RI(a) scanf("%d",&a)
#define mset(a,val,n) for(int i=0;i<n;i++)a[i]=val;
#define mset2(a,val,n,m) for(int i=0;i<n;i++)for(int j=0;j<m;j++)a[i][j]=val;
#define FI freopen("in.txt","r",stdin)
#define FO freopen("out.txt","w",stdout)
using namespace std;
typedef long long LL;
char s[888],buf[888];
bool ischar(char c) {
return (c>='A'&&c<='Z')||(c>='a'&&c<='z');
}
int main() {
cin.getline(s,888);
int n=strlen(s),flag=0;
_for(i,0,n)if(s[i]=='@') {
int l=++i;
while(i<n&&ischar(s[i]))
buf[i-l]=s[i++];
if(strlen(buf)) {
if(flag)cout<<" ";flag=1;
cout<<buf;
}
mset(buf,0,n);
}
}