标题:代码貌似有问题,但输出结果是对的,求解?
取消只看楼主
peng880610
Rank: 3Rank: 3
等 级:论坛游侠
帖 子:128
专家分:123
注 册:2017-3-29
结帖率:100%
已结贴  问题点数:17 回复次数:1 
代码貌似有问题,但输出结果是对的,求解?
编译代码,输出乘法口诀
#include <stdio.h>
#include <conio.h>
int main()
{
    int i=1,j=1;
    for(i=1;i<=9;i++)
    {

        if(j==1)
        {

           for(j=1;j<2;j++)
              {

            int res;
            res=i*j;
            printf("%d*%d=%-3d ",j,i,res);
        }

        printf("\n");
        }

        else if(j>=1 && j<=2)
        {
            for(j=1;j<3;j++)
            {

                int res;
                res=i*j;
            printf("%d*%d=%-3d ",j,i,res);
        }

        printf("\n");
        }
        else if(j>=1 && j<=3)
        {
            for(j=1;j<4;j++)
                {
                    int res;
                    res=i*j;
                    printf("%d*%d=%-3d ",j,i,res);
                }
                printf("\n");
            }
        else if(j>=1 && j<=4)
        {
            for(j=1;j<5;j++)
                {
                    int res;
                    res=i*j;
                    printf("%d*%d=%-3d ",j,i,res);
                }
                printf("\n");
            }

        else if(j>=1&&j<=5)
        {
            for(j=1;j<6;j++)
                {
                    int res;
                    res=i*j;
                    printf("%d*%d=%-3d",j,i,res);
                }
                printf("\n");
            }

        else if(j>=1 && j<=6)
        {
            for(j=1;j<7;j++)
                {
                    int res;
                    res=i*j;
                    printf("%d*%d=%-3d",j,i,res);
                }
                printf("\n");
            }

            else if(j>=1 && j<=7)
            {
                for(j=1;j<8;j++)
                    {
                        int res;
                        res=i*j;
                        printf("%d*%d=%-3d",j,i,res);
                    }
                    printf("\n");
                }

            else if(j>=1 && j<=8)
            {
                for(j=1;j<9;j++)
                    {
                        int res;
                        res=i*j;
                        printf("%d*%d=%-3d",j,i,res);
                    }
                    printf("\n");
                }

            else if(j>=1  && j<=9)
            {
                for(j=1;j<10;j++)
                    {
                        int res;
                        res=i*j;
                        printf("%d*%d=%-3d",j,i,res);
                    }
                    printf("\n");
                }



        }

        printf("\n");

    getch();
    return 0;
}
搜索更多相关主题的帖子: include 
2017-05-30 16:49
peng880610
Rank: 3Rank: 3
等 级:论坛游侠
帖 子:128
专家分:123
注 册:2017-3-29
得分:0 
感谢,看了你们写的,再看看我写的,真的可以用乱码来形容了。。。
2017-05-30 18:20



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




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

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