C語言嵌套循環之輸出九九乘法表


//輸出九九乘法表  
#include <stdio.h>

int main()
{
    int m,n;
    for(m=1;m<=9;m++)
    {
        n=1;
        for(n=1;n<=9;n++)
        {
            printf("%4d",m*n);
        }
        printf("\n");
    }
    return 0;
}
//輸出下三角九九乘法表
#include <stdio.h>

int main()
{
    int m,n;
    for(m=1;m<=9;m++)
    {
        n=1;
        for(n=1;n<=m;n++)
        {
            printf("%4d",m*n);
        }
        printf("\n");
    }
    return 0;
}
//輸出上三角九九乘法表
#include <stdio.h>
int main()
{
    int m, n, t;
    for (m=1;m<=9;m++)
    {
        for (n=m; n<=9 ;n++)
        {
            printf("%4d",m*n);
        }
            printf("\n");
        for (t=0; t<m ; t++)
        {
            printf("    ");
        }
    }
    return 0;
}

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM