| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 738 人关注过本帖
标题:求高手解答!非常感谢!
只看楼主 加入收藏
yqb139130
Rank: 1
等 级:新手上路
帖 子:7
专家分:0
注 册:2011-5-31
结帖率:0
收藏
 问题点数:0 回复次数:16 
求高手解答!非常感谢!
  0  0  0  0  1  0  0  0  0  0  0  0  0  0  0  0
  0  0  0  0  0  0  0  0  0  1  0  0  0  0  0  0
  0  0  0  0  0  0  0  0  0  0  0  0  0  0  1  0
  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0
  1  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0
  0  0  0  0  0  0  0  0  0  0  0  0  0  1  0  0
  0  0  0  0  0  0  0  0  0  0  1  0  0  0  0  0
  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0
  0  0  0  0  0  0  0  0  0  0  0  0  1  0  0  0
  0  1  0  0  0  0  0  0  0  0  0  0  0  0  0  0
  0  0  0  0  0  0  1  0  0  0  0  0  0  0  0  0
  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0
  0  0  0  0  0  0  0  0  1  0  0  0  0  0  0  0
  0  0  0  0  0  1  0  0  0  0  0  0  0  0  0  0
  0  0  1  0  0  0  0  0  0  0  0  0  0  0  0  0
  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0
16*16的矩阵,其中4,8,12,16行都是0,其他行只有一个1,一共12个1.
要求每行每列有且只有一个1(除了4,8,12,16行、列必须为0)。输出所有不同的矩阵。
//同学说可以建一个list,1-16个,将矩阵中1的位置坐标放在list中,分为行号和列号。 我还是不会做,
求高人解答,万分感谢!
2011-05-31 14:42
laigaoat2005
Rank: 4
等 级:业余侠客
帖 子:388
专家分:226
注 册:2007-4-5
收藏
得分:0 
输出所有不同的矩阵。
输出所有不同的矩阵?结果那么多,输出了怎么能看完?不用看完,只求算法?
2011-05-31 20:41
yqb139130
Rank: 1
等 级:新手上路
帖 子:7
专家分:0
注 册:2011-5-31
收藏
得分:0 
没有这么多,每行每列只能有一个1,12*12,一共144种!每个1的行号和列号都可以从1-16变化,其中不包括4,8,12,16,所以每个1的行号和列号各有12种!,组合一共有144种!求高人帮忙编程指点啊!
每行每列只能有一个1!!!!!!
2011-05-31 22:16
laigaoat2005
Rank: 4
等 级:业余侠客
帖 子:388
专家分:226
注 册:2007-4-5
收藏
得分:0 
晕了,题看错了……  只看到了每行只能有个1,没有看到每行每列只有一个1……
每列啊,哎。这么简单的题让人郁闷半天。还是给个程序出来吧。
程序代码:
#include <stdio.h>
int main(void)
{
    for(int i=0;i<15;i++)
    {       
        for (int j=0;j<15;j++)
            if( i!=j || 3==i || 7==i || 11==i || 15==i ) printf("0");
            else printf("1");
    printf("\n");
    }
    return 0;
}

 
2011-05-31 22:24
laigaoat2005
Rank: 4
等 级:业余侠客
帖 子:388
专家分:226
注 册:2007-4-5
收藏
得分:0 
你求高手解题,我以为好难,没有注意看 每列都只能有个1,以为会有好多结果哦……真郁闷!
2011-05-31 22:30
laigaoat2005
Rank: 4
等 级:业余侠客
帖 子:388
专家分:226
注 册:2007-4-5
收藏
得分:0 
急人,怎么还是不对。还没有偏移
2011-05-31 22:35
yqb139130
Rank: 1
等 级:新手上路
帖 子:7
专家分:0
注 册:2011-5-31
收藏
得分:0 
呵呵,你看清楚了,没有那么多情况的,我限定条件了
2011-05-31 22:47
laigaoat2005
Rank: 4
等 级:业余侠客
帖 子:388
专家分:226
注 册:2007-4-5
收藏
得分:0 
这下应该对了。哎,没有分也没有关系。当做一个练习题。
程序代码:
#include <stdio.h>

void putout(int cnt=1)
{
    for(int count=1, i=1+cnt;count<=16;  count++,i++)
    {   
        if(16==i) i=1;   
        for (int j=1;j<16;j++)
            if( i!=j || 4==count || 8==count || 12==count || 16==count ) printf("0");
            else printf("1");
    printf("\n");
    }   
    printf("\n\n\n");
}

int main(void)
{   
    for (int cnt=0;cnt<15;cnt++)
    {
        putout(cnt);
    }

    return 0;
}

2011-05-31 23:04
laigaoat2005
Rank: 4
等 级:业余侠客
帖 子:388
专家分:226
注 册:2007-4-5
收藏
得分:0 
哎,还是不对。还是没有打全。真难。收回我上面说简单的话。我暂时做不出来了。能力不够。盼高手。
2011-05-31 23:13
laigaoat2005
Rank: 4
等 级:业余侠客
帖 子:388
专家分:226
注 册:2007-4-5
收藏
得分:0 
再进化一次:
可能还是不全,但,我觉得这种算法只能算到这这里了。没有学过算法,思维不够。
程序代码:
#include <stdio.h>

void putout(int cnt=1)
{
    for(int count=1, i=1+cnt;count<=16;  count++,i++)
    {   
        if(16==i) i=1;   
        for (int j=1;j<16;j++)
            if( i!=j || 4==count || 8==count || 12==count || 16==count ) printf("0");
            else printf("1");
    printf("\n");
    }   
    printf("\n\n\n");
}

void putout_fan(int cnt=1)
{
    for(int count=1, i=1+cnt;count<=16;  count++,i++)
    {   
        if(16==i) i=1;   
        for (int j=16;j>0;j--)
            if( i!=j || 4==count || 8==count || 12==count || 16==count ) printf("0");
            else printf("1");
    printf("\n");
    }   
    printf("\n\n\n");
}

int main(void)
{   
    for (int cnt=0;cnt<15;cnt++)
    {
        putout(cnt);
        putout_fan(cnt);
    }

    return 0;
}

2011-05-31 23:21
快速回复:求高手解答!非常感谢!
数据加载中...
 
   



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

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