| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1316 人关注过本帖
标题:代码貌似有问题,但输出结果是对的,求解?
取消只看楼主 加入收藏
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
快速回复:代码貌似有问题,但输出结果是对的,求解?
数据加载中...
 
   



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

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