| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
Re:帮忙看看哪里出错了In Reply To:帮忙看看哪里出错了 Posted by:l21c at 2006-02-22 00:20:23 #include <string>
#include <iostream>
#include <vector>
using namespace std;
void print(char ch, int times)
{
for (int i=0; i<times; i++)
// if (ch>='a' && ch<='z')
cout << ch;
}
void doit(string str1, string str2)
{
//cout << str1 << str2 << endl;
vector< int > data1, data2;
data1.assign(256, 0);
data2.assign(256, 0);
for (int i=0; i<str1.size(); i++)
{
++data1[str1[i]];
}
for (i=0; i<str2.size(); i++)
++data2[str2[i]];
for (i=0; i<data1.size(); i++)
{
int small = data1[i]<data2[i]?data1[i]:data2[i];
if (small>0)
print(i, small);
}
cout << endl;
}
int main()
{
char *str1, *str2;
str1 = new char[200], str2 = new char[200];
while (gets(str1) && gets(str2))
// cin >> str1 >> str2;
doit(str1, str2);
return 0;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator