![]() |
#2
lz10919149992012-10-14 20:06
|
这是题目链接
下面是我写的代码,不知道哪里出错啦,求帮忙看看!!!

#include <iostream>
#include <string.h>
using namespace std;
int main()
{
char a[101];
while (cin>>a)
{
int count = 0;
int i,j,m,n,x;
char b[101][101] = {0};
while (a[count] != '\0')
{
count++;
}
for (i=0; i<count; i++)
{
for (j=0; j<count; j++)
{
b[j][(j+i+count)%count] = a[i];
}
}
for (m=0; m<count-1; m++)
{
if (strcmp(b[m], b[m+1]) < 0)
{
char temp[101];
strcpy(temp, b[m]);
strcpy(b[m], b[m+1]);
strcpy(b[m+1], temp);
}
}
for (n=0; n<count; n++)
{
if (strcmp(b[n], b[count-1]) == 0)
{
cout<<b[n]<<endl;
}
}
}
return 0;
}
#include <string.h>
using namespace std;
int main()
{
char a[101];
while (cin>>a)
{
int count = 0;
int i,j,m,n,x;
char b[101][101] = {0};
while (a[count] != '\0')
{
count++;
}
for (i=0; i<count; i++)
{
for (j=0; j<count; j++)
{
b[j][(j+i+count)%count] = a[i];
}
}
for (m=0; m<count-1; m++)
{
if (strcmp(b[m], b[m+1]) < 0)
{
char temp[101];
strcpy(temp, b[m]);
strcpy(b[m], b[m+1]);
strcpy(b[m+1], temp);
}
}
for (n=0; n<count; n++)
{
if (strcmp(b[n], b[count-1]) == 0)
{
cout<<b[n]<<endl;
}
}
}
return 0;
}