bLue的文件查找器
Time Limit: 1000MS Memory Limit: 65536KB
ProblemDescription
bLue的电脑里存了各种各样的文件,随着文件越来越多,查找文件也成了一个麻烦事。
现在,他想要查找所有指定格式(扩展名)的文件,不过他并不会使用文件管理器自带的搜索功能,所以他想求你写一个文件查找器,来帮他查找所有指定格式的文件。
Input
输入数据有多组(数据组数不超过 100),到 EOF 结束。
对于每组数据:
- 第一行输入一个整数 n (1 <= n <= 100) 和一个长度不超过 5 的字符串 ex,分别表示文件夹内的文件数量和要查找的文件的扩展名。
 - 接下来的 n 行,每行输入一个完整文件名。保证文件名不包含空格且长度不超过 100。
 
Output
对于每组数据,按照输入顺序输出文件夹内所有扩展名符合查找要求的文件名。
ExampleInput
6 cpp   3717.cpp   xunhuansai_daima.zip   xunhuansai_jietibaogao.pdf   C.cpp   bLue.jpg   cyk_de_richang.mp4  ExampleOutput
3717.cpp   C.cpp  Hint
Author
「2016年第六届ACM趣味编程循环赛 Round #2」bLue
#include <iostream>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stdio.h>
#define cmax 100003
using namespace std;
int main()
{
   int n;
   char e_ex[6],ex[6],wenjian[200];
   while(~scanf("%d",&n))
   {
       scanf("%s",ex);
       for(int j=0;j<n;j++)
       {
       scanf("%s",wenjian);
         for(int i=0;wenjian[i];i++)
         {
              if(wenjian[i]=='.')
              {
                  strcpy(e_ex,wenjian+i+1);
                  break;
              }
         }
          if(!strcmp(e_ex,ex))
          cout<<wenjian<<endl;
       }
   }
}
/***************************************************
User name: jk160505徐红博
Result: Accepted
Take time: 12ms
Take Memory: 356KB
Submit time: 2017-01-16 10:38:25
****************************************************/
/***************************************************
User name: jk160505徐红博
Result: Accepted
Take time: 4ms
Take Memory: 148KB
Submit time: 2017-01-16 16:22:42
****************************************************/
  
  

京公网安备 11010502036488号