ZOJ Problem Set - 2947 Abbreviation

来源:互联网 发布:直播那个软件最好 编辑:程序博客网 时间:2024/06/05 23:03
#include <iostream>#include <string>using namespace std;int main(){int T , N , temp , flag;char word[6];string s;cin>>T;while (T--){flag = 1;cin>>N;for (int i = 0; i < N; i++){cin>>s;word[i] = s[0];}cin>>temp;if (N != temp){flag = 0;for (int i = 0; i < temp; i++) { //注意要添加次循环输入,才能符合输入的要求 cin>>s;}}else{for (int i = 0; i < N; i++){cin>>s;if (s[0] != word[i]){flag = 0;}}}if (flag) cout<<"SAME"<<endl;else cout<<"DIFFERENT"<<endl;}return 0;}

0 0
原创粉丝点击