大牛帮忙看下一道题,toj2943

来源:百度知道 编辑:UC知道 时间:2024/06/08 12:22:56
代码:
#include<iostream>

using namespace std;

bool check(char *s1, char *s2, int len)
{
int cnt[26] = {0};
for(int i = 0; i < len; i++)
{
cnt[s1[i]-'a']++; cnt[s2[i]-'a']--;
}
for(int i = 0; i < 26; i++)
{
if(cnt[i])
return 0;
}
return 1;
}

char letter[500][20];
char dictionary[100][20];
char temp[1];

int main()
{
int number,i,j,k,m,n,count=0;
cin >> number;

for(i = 0 ; i < number ; i++)
cin >> dictionary[i];

for(j = 0 ; j < 500 ; j++)
{
cin >> letter[j];
for(k = 0 ; k < number ; k++)
{
if(letter[j][0] == dictionary[k][0]
&&letter[j][strlen(letter[j])-1] == dictionary[k][strlen(dictionary[k])-1]
&&strlen(letter[j]) == strlen(dictionary[k]))
{
if(check(lette

vc里是没有什么大的问题呀,看看下面的代码:

#include<iostream>
#include<time.h>
#include<stdlib.h>
using namespace std;

bool check(char *s1, char *s2, int len)
{
int cnt[26] = {0};
for(int i = 0; i < len; i++)
{
cnt[s1[i]-'a']++; cnt[s2[i]-'a']--;
}
for(i = 0; i < 26; i++) /*重新定义了*/
{
if(cnt[i])
return 0;
}
return 1;
}

char letter[500][20];
char dictionary[100][20];
char temp[1];

int main()
{
int number,i,j,k,count=0; //m,n没有用到
cin >> number;

for(i = 0 ; i < number ; i++)
cin >> dictionary[i];

for(j = 0 ; j < number ; j++) //这里500个你输入得了那么多个嘛? 输入的手软
{
cin >> letter[j];
for(k = 0 ; k < number ; k++)
{
if(letter[j][0] == dictionary[k][0]
&&letter[j][strlen(letter[j])-1] == dictionary[k][strlen(dictionary[k