题目大意:给出M个字符串和N个字符串,要求将M个字符串和N个字符串分别首尾相连,问能连成几个不一样的字符串
解题思路:好坑的一题,读取M,N的时候,后面可能有空格,所以还要gets()一下,还有读取字符串的时候也可能有空格,所以只能整行读取。。。
#include<cstdio>
#include<cstring>
#include<iostream>
#include<set>
using namespace std;
char s[100];
int M,N;
int main() {
int test, mark = 1;
cin >> test;
while(test--) {
scanf("%d %d",&M,&N);
gets(s);
string str2[2000], str1[2000],str;
set<string> s;
for(int i = 0; i < M; i++)
getline(cin,str1[i]);
for(int i = 0; i < N; i++)
getline(cin,str2[i]);
for(int i = 0; i < M; i++)
for(int j = 0; j < N; j++) {
s.insert(str1[i]+str2[j]);
}
cout << "Case " << mark++ << ": " << s.size() << endl;
}
return 0;
}