栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > C/C++/C#

学习c语言练习题

C/C++/C# 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

学习c语言练习题

题目如下;
 

填表格
将1、2、3、4、5和6填入2行3列的表中,要使得每一个列右边的数字比左边的数字大,每一行下面的数字比上面的数字大。按此要求,可有几种填写方法?
**输出提示信息:"The possible table satisfied above conditions are:n"
**输出格式要求:"nNo.:%d" "n%3d"  "%3d"

代码如下:

#include 

int main()
{
    int a[6],count=0;
    a[0]=1;
    a[5]=6;
    printf("The possible table satisfied above conditions are:n");
    for(int i=2;i<=5;i++)
    {
        for(int j=2;j<=5;j++)
        {
            for(int k=2;k<=5;k++)
            {
                for(int l=2;l<=5;l++)
                {
                    a[1]=i;
                    a[2]=j;
                    a[3]=k;
                    a[4]=l;
                    if(a[1]a[3]&&a[2]>a[1]&&a[1]!=a[4]&&a[2]!=a[1]&&a[4]!=a[3]&&a[1]!=a[3]&&a[2]!=a[3]&&a[2]!=a[4])
                    {
                        count++;
                        printf("nNo.:%d",count);
                        printf("n%3d",a[0]);
                        for(int n=1;n<6;n++)
                        {
                            printf("%3d",a[n]);
                            if(n==2)
                            {
                                printf("n");
                            }
                        }
                    }
                }
            }
        }
    }
return 0;
}

欢迎交流。

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/869650.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号