比赛 20150711暑期B班 评测结果 AAAAAAAAAA
题目名称 单词缩写 最终得分 100
用户昵称 Saionji 运行时间 0.006 s
代码语言 C++ 内存使用 0.29 MiB
提交时间 2015-07-11 11:25:46
显示代码纯文本
#include <cstdio>
#include <cstring>

const int MAX = 200;

int i;

void CL(char *str);
int SPq(char *dest, char *src, int &p, int len);

int main(void)
{
	FILE *fin = fopen("abbreviation.in", "r");
	FILE *fout = fopen("abbreviation.out", "w");
	int n;
	char name[MAX];
	char word[MAX];
	fscanf(fin, "%d", &n);
	fgets(name, MAX-1, fin);
	while(n--)
	{
		fgets(name, MAX-1, fin);
		int len = strlen(name);
		while((name[len - 1] > 'z')||(name[len - 1] > 'Z' && name[len - 1] < 'a')||name[len - 1] < 'A')
			name[--len] = 0;
		CL(name);
		int ptr = 0;
		while(SPq(word, name, ptr, len))
			if(!strcmp(word, "AND")||!strcmp(word, "FOR")||!strcmp(word, "THE")||strlen(word) < 3)
				continue;
			else
				fprintf(fout, "%c", word[0]);
		fprintf(fout, "\n");
	}
	fclose(fin);
	fclose(fout);
	return 0;
} 
void CL(char *str)
{
	int len = strlen(str);
	for(i=0;i<len;i++)
		if(str[i]>='a'&&str[i]<='z')
			str[i]-=32;
}
int SPq(char *word, char *name, int &p, int len)
{
	i = 0;
	while(name[p]!=' '&&p<len)
		word[i++] = name[p++];
	word[i] = 0;
	p++;
	if(i)
		return 1;
	else
		return 0;
}