标题:改程序 已经改了一个 但是运行有问题
只看楼主
轻语灬娜
Rank: 1
等 级:新手上路
帖 子:7
专家分:1
注 册:2016-3-21
结帖率:0
 问题点数:0 回复次数:1 
改程序 已经改了一个 但是运行有问题
源代码:
#include <stdio.h>
int main()
{
        int a[4] = {1, 2, 3, 4};
        int i, j, k;
        int t = 1 << 13;
        for (i = 0; i < t; i++)
        {
                j = i;
                k = 0;
                printf("{");
                while (j)
                {
                        if (j & 1)
                        {
                                printf("%d", a[k]);
                        }
                        j >>= 1;
                        ++k;
                }
                printf("}\n");
        }
        return 0;
}
求大神改成13个字母输出所有子集输出并压到文件的程序
搜索更多相关主题的帖子: include 源代码 
2016-06-20 20:41
轻语灬娜
Rank: 1
等 级:新手上路
帖 子:7
专家分:1
注 册:2016-3-21
得分:0 
#include <stdio.h>
#include<stdlib.h>
#include<time.h>
void srant(char *c)
{
    int i,j,k;
    srand((unsigned)time(NULL));
    i=rand()&1;
    for(j=0;j<13;j++)   //i用来控制产生的字母是大写还是小写
    {
        if(i==0)
        c[j]='A'+rand()%26;
    else
        c[j]='a'+rand()%26;
    }
     for(k=0;k<13;k++)
        printf("%c",c[k]);
}
int print(char *c)
{
        int i, j, k, m=0;
        int t = 1 << 13;
        for (i = 0; i < t; i++)
        {
                j = i;
                k = 0;
                printf("{");
                while (j)
                {
                        if (j & 1)
                        {
                                printf("%c", c[k]);

                        }
                        j >>= 1;
                        ++k;

                }
                printf("}\n");
                m++;
        }
        printf("%d",m);
        return 0;
}
int main()
{
        char c[13];
        srant(c);
        printf("\n");
        print(c);
        return 0;
}
2016-06-21 07:44



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-466171-1-1.html




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

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