A FZU-2054

水题,比较A,B双方的最大值即可。

B FZU-2055

string,截取‘.’之前和之后然后和给出的文件夹名和拓展名比较就好了啊,不明白为什么那么多人错。

代码:

 1 #include<iostream>
 2 #include<cstdio>
 3 #include<cstdlib>
 4 #include<cmath>
 5 #include<string>
 6 #include<algorithm>
 7 using namespace std;
 8 typedef long long LL;
 9 const int maxn = 100100;
10 string path[maxn], type[maxn];
11 int main()
12 {
13     int T; scanf("%d", &T);
14     while(T--)
15     {
16         int n, m; scanf("%d%d", &n, &m);
17         string str;
18         for(int i = 0; i < n; i++)
19         {
20             cin >> str;
21             int pos = str.find_last_of('.');
22             path[i] = str.substr(0, pos);
23             type[i] = str.substr(pos);
24         }
25         string t1, t2;
26         for(int i = 0; i < m; i++)
27         {
28             cin >> t1 >> t2;
29             for(int j = 0; j < n; j++)
30             {
31                 if(t2 != type[j]) continue;
32                 if(t1.length() > path[j].length()) continue;
33                 string tmp =  path[j].substr(0, t1.length());
34                 if(tmp == t1) {cout << path[j] << type[j] << endl;}
35             }
36         }
37 
38     }
39     return 0;
40 }
View Code

相关文章:

  • 2022-03-07
  • 2022-12-23
  • 2021-05-20
  • 2021-10-13
  • 2021-11-13
  • 2022-12-23
  • 2021-06-16
  • 2022-01-22
猜你喜欢
  • 2021-08-30
  • 2021-08-02
  • 2022-12-23
  • 2021-09-20
  • 2021-09-27
  • 2022-12-23
相关资源
相似解决方案