#include
#define PAIR_SIZE 2
#define CASE_SIZE 5
void areBrotherStrings(char *string[][PAIR_SIZE])
{
int i = 0;
int j = 0;
int k = 0;
int l = 0;
for(i=0; i
for(j=0; j
if(strlen(string[i][j]) == strlen(string[i][j+1]))
{
for(k=0; *(string[i][j]+k)!='\0'; k++)
{
for(l=0; *(string[i][j+1]+l)!='\0'; l++)
{
if (*(string[i][j]+k) == *(string[i][j+1]+l))
{
break;
}
else if(l==strlen(string[i][j+1])-1)
{
goto circle;
}
}
}
printf("%s = %s\n",string[i][j],string[i][j+1]);
}
else
{
circle:
continue;
}
}
}
}
int main()
{
char *testCases[CASE_SIZE][PAIR_SIZE] = {{"a","a"},{"abcda","daab"},{"abcda", "cdaba"},{"asdfghjkl","lkjhgfdsa"},{"!@#$%^&*()_+", "$%^&*()_+!@#"}};
printf("兄弟字符串是:\n");
areBrotherStrings(testCases);
return 0;
}
这时作业吗,怎么刚才就有个人问?
还有一种思路就是先调用qsort函数排序,再调用strcmp函数比较,这种方法应该比较简单,但是需要调用库函数,你可以自己试试看