zju 2947

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;
}

zju 2947,布布扣,bubuko.com

时间: 2024-10-06 01:29:38

zju 2947的相关文章

zju 2947 试探

#include <iostream> using namespace std; int main(int argc, char *argv[]) { int i,n,m; char data1[10][20],data2[10][20]; scanf("%d",&n); for (i=0;i<n;i++) scanf("%s",&data1[i]); scanf("%d",&m); for (i=0;i

HDU 4800 &amp; ZJU 3735 Josephina and RPG(状压dp)

题目链接: ZJU:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=5081 HDU:http://acm.hdu.edu.cn/showproblem.php?pid=4800 Problem Description A role-playing game (RPG and sometimes roleplaying game) is a game in which players assume the roles of c

ZJU 2676 Network Wars

Network Wars Time Limit: 5000ms Memory Limit: 32768KB This problem will be judged on ZJU. Original ID: 267664-bit integer IO format: %lld      Java class name: Main Special Judge Network of Byteland consists of n servers, connected by m optical cable

zju 1763

#include <iostream> #include <cstdio> using namespace std; int main(int argc, char *argv[]) { double a,b; cin>>a; while (cin>>b) { if (b==999) { printf("End of Output\n"); break; } printf("%.2f\n",(b-a)); a=b; }

[ACM] POJ 2947 Widget Factory (高斯消元)

Widget Factory Time Limit: 7000MS   Memory Limit: 65536K Total Submissions: 4436   Accepted: 1502 Description The widget factory produces several different kinds of widgets. Each widget is carefully built by a skilled widgeteer. The time required to

人生第一场组队赛---2014.8 zju monthly

暑期集训中段就组了队,不过一直没机会打比赛 昨天kitkat突然发现了zju要搞月赛,我想了一下题目对于我这种渣实在是有点难,于是想到干脆打一次组队赛吧,跟队友商量了一下也同意了 12点---17点  5小时 10道题 虽然难度比一般现场赛低一些 不过形式上差不多 应该还算一次不错的练习机会 比赛开始 zh0ng神从前往后读,kitkat从后往前读,我则在中间乱看 我先看了E,感觉是个dp,但是又有点模糊,kitkat读了J,一个字符串题,题意很简单,可是也没什么好的解决办法(最后发现j是全场最

zju 2744 回文字符 hdu 1544

#include<iostream> #include<algorithm> using namespace std; int main() { string s; while(cin>>s) { int i,begin,end,total = s.size(),l = s.size(); for(i = 0 ; i < s.size(); ++i) { begin = i - 1; end = i+1;//当字符串长度为奇数时 while(s[begin]==s

zju 1251 Bricks box 砖盒----------hdu 1326

#include <iostream> using namespace std; int main() { int a[51],n,k=1; while(cin>>n,n) { int i,ans=0,s=0; for(i=0;i<n;i++) { cin>>a[i]; s+=a[i]; } s/=n; for(i=0;i<n;i++) if(a[i]>s)ans+=a[i]-s; cout<<"Set #"<&l

zju 1115 Digital roots 数字根

#include <iostream> #include <string> using namespace std; int main() { string n; while(cin>>n,n!="0") { int s=0,l=n.length(); for(int i=0;i<l;i++) s+=n[i]-'0'; while(s>9) s=s/10+s%10; cout<<s<<endl; } return