标签:style blog http color os strong io 数据
http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=2947
错误----
#include<iostream> #include<string> #include<cstdio> #include<cstring> using namespace std; int main() { int t,n,m,i; char data1[10][20],data2[10][20]; string s1,s2; s1=""; s2=""; cin>> t; while(t--) { cin>>n; for(i=0;i<n;i++) { cin>>data1[i]; s1=s1+data1[i][0]; } cin>>m ; for(i=0;i<m;i++) { cin>>data2[i]; s2=s2+data2[i][0]; } if(n!=m||s1!=s2) cout<<"DIFFERENT"<<endl; else cout<<"SAME"<<endl; } return 0; }
正确---
我的
#include<iostream> #include<string> #include<cstdio> #include<cstring> using namespace std; int main() { int t,n,m,i; cin>>t; while(t--) { char data1[100][200],data2[100][200]; string s1,s2; s1=""; s2=""; cin>>n; for(i=0;i<n;i++) { cin>>data1[i]; s1=s1+data1[i][0]; } cin>>m; for(i=0;i<m;i++) { cin>>data2[i]; s2=s2+data2[i][0]; } //cout<<s1<<endl;cout<<s2<<endl; if(m!=n||s1!=s2) cout<<"DIFFERENT"<<endl; else cout<<"SAME"<<endl; } return 0; }
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
using namespace std;
int main() {
int t,n,m,i;
cin>>t;
while(t--)
{
char data1[100][200],data2[100][200];
string s1,s2;
s1=""; s2="";
cin>>n;
for(i=0;i<n;i++)
{
cin>>data1[i];
s1=s1+data1[i][0];
}
cin>>m;
for(i=0;i<m;i++)
{
cin>>data2[i];
s2=s2+data2[i][0];
}
//cout<<s1<<endl;cout<<s2<<endl; 测试数据
if(m!=n||s1!=s2) cout<<"DIFFERENT"<<endl;
else cout<<"SAME"<<endl;
}
return 0;
}
**************************************************************************************************************************************************
网上搜的
#include <iostream> #include <stdio.h> #include <string> using namespace std; int main () { string s,a,b; a=" "; b=" "; int t,n,m;cin>>t; for(int i=0;i<t;i++) { cin>>n; for(int j=0;j<n;j++) { cin>>s; a=a+s[0]; } cin>>m; for(int k=0;k<m;k++) { cin>>s; b=b+s[0]; } if(a.compare(b)==0) printf("SAME\n"); else printf("DIFFERENT\n"); } return 0; }
#include<iostream> #include<string> #include<cstdio> #include<cstring> using namespace std; int main() { int t,n,m,i; char a[500]; string s1,s2; cin>> t; while(t--) { cin>>n; getchar(); s1=""; //qing kong for(i=0;i<n;i++) { cin>>a; s1+=a[0]; } cin>>m; getchar(); s2=""; for(i=0;i<m;i++) { cin>>a; s2+=a[0]; } if(n!=m||s1!=s2) cout<<"DIFFERENT"<<endl; else cout<<"SAME"<<endl; } return 0; }
标签:style blog http color os strong io 数据
原文地址:http://www.cnblogs.com/2014acm/p/3883835.html