记录编号 |
170097 |
评测结果 |
AAAAAAAAAA |
题目名称 |
[暑假培训2012] 单词缩写 |
最终得分 |
100 |
用户昵称 |
NVIDIA |
是否通过 |
通过 |
代码语言 |
C++ |
运行时间 |
0.019 s |
提交时间 |
2015-07-12 11:09:05 |
内存使用 |
0.29 MiB |
显示代码纯文本
#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;
}