| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 669 人关注过本帖
标题:1道题,不知道那里错啦 求大神分析
取消只看楼主 加入收藏
lishenming
Rank: 1
等 级:新手上路
帖 子:9
专家分:0
注 册:2011-9-14
结帖率:100%
收藏
已结贴  问题点数:20 回复次数:4 
1道题,不知道那里错啦 求大神分析
http://acm.whu.
这是题目链接

下面是我写的代码,不知道哪里出错啦,求帮忙看看!!!
程序代码:
#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;
}

搜索更多相关主题的帖子: 链接 
2012-10-14 18:54
lishenming
Rank: 1
等 级:新手上路
帖 子:9
专家分:0
注 册:2011-9-14
收藏
得分:0 
回复 2楼 lz1091914999
他不是要求输出各种可能的情况么?你这应该只能输出一种吧??

还有我的代码错在哪里啊??

麻烦你啦 谢谢
2012-10-15 10:27
lishenming
Rank: 1
等 级:新手上路
帖 子:9
专家分:0
注 册:2011-9-14
收藏
得分:0 
怎么没有人啊 。。。
2012-10-16 11:09
lishenming
Rank: 1
等 级:新手上路
帖 子:9
专家分:0
注 册:2011-9-14
收藏
得分:0 
回复 5楼 liman123
我自己编译是没有错误的  只是系统说我答案错误 。。。

我也不知道错在哪里。。
2012-10-17 13:19
lishenming
Rank: 1
等 级:新手上路
帖 子:9
专家分:0
注 册:2011-9-14
收藏
得分:0 
回复 7楼 cj657206427
DescriptionSome beads are embedded in a bracelet, and each beads is carved with a lower case letter, as the follow figure shows:
 
If we read the letters in counter clockwise with different initial position, we may get different strings. The above example, we can read 6 strings:
acabdb
cabdba
abdbac
bdbaca
dbacab
bacabd
Sort these strings in lexical order, we obtain:
abdbac
acabdb
bacabd
bdbaca
cabdba
dbacab
What we need is the first string: abdbac.

InputA
string of lower case letters representing the letters carved on the bracelet (in counter clockwise order).
The length of the string is no more than 100.OutputOutput the first string of all the possible strings after sorting them in lexical order.Sample

Input

acabdb
kkisverystupid
Sample Output

abdbacd
kkisverystupi
2012-10-17 14:07
快速回复:1道题,不知道那里错啦 求大神分析
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.017392 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved