所有新聞群組討論區列表 風禹科技驗證有限公司 Web News Reader

目前新聞群組:tw.bbs.comp.oop

項目 內容
發文者 肉腳布
日期 2007/1/3 下午 01:20:01
標題 6.利用printf函式列印一張九九乘法表
檔頭
220 24516 <4RlQFe$0vq@bbs.mgt.ncu.edu.tw> article
Path: netnews!ctu-gate!news.nctu.edu.tw!news.ncu.edu.tw!news.mgt.ncu.edu.tw!bbs
From: brucetsao.bbs@bbs.mgt.ncu.edu.tw (肉腳布)
Newsgroups: tw.bbs.comp.oop
Subject: 6.利用printf函式列印一張九九乘法表
Date: 03 Jan 2007 05:20:01 GMT
Organization: 中央資管龍貓資訊天地
Lines: 33
Message-ID: <4RlQFe$0vq@bbs.mgt.ncu.edu.tw>
NNTP-Posting-Host: bbs.mgt.ncu.edu.tw
Mime-Version: 1.0
Content-Type: text/plain; charset="big5"
Content-Transfer-Encoding: 8bit
X-Trace: news.mgt.ncu.edu.tw 1167801917 53462 140.115.83.240 (3 Jan 2007 05:25:17 GMT)
X-Complaints-To: usenet@news.mgt.ncu.edu.tw
NNTP-Posting-Date: Wed, 3 Jan 2007 05:25:17 +0000 (UTC)
X-Filename: OOP/M.1167801592.A
Xref: netnews tw.bbs.comp.oop:24516
內文
6.      利用printf函式列印一張九九乘法表
6.      利用printf函式列印一張九九乘法表,其對齊格式如下:
        ×              2               3               4               5               6               7               8               9
        2               4               6               8               10              12              14              16              18
        3               6               9               12              15              18              21              24              27
        4               8               12              16              20              24              28              32              36
        5               10              15              20              25              30              35              40              45
        6               12              18              24              30              36              42              48              54
        7               14              21              28              35              42              49              56              63
        8               16              24              32              40              48              56              64              72
        9               18              27              36              45              54              63              64              81
(提示:使用一個for巢狀迴圈,外圈是2~9,內圈也是2~9。至於對齊的方法可以使用printf函式,並指定列印整數的格式為%3d。)

        #include <stdio.h>
        void main()
        {
                int i,j;
                printf("  x |");
                for (i=2;i<=9;i++) printf("%3d",i);
                printf("\n----+-------------------------\n");
                for (i=2;i<=9;i++)
                {
                        printf("%3d |",i);
                        for (j=2;j<=9;j++)
                                printf("%3d",i*j);
                        printf("\n");
                }
}

--
◎龍貓資訊天地(bbs.mgt.ncu.edu.tw)
◎[brucetsao]From: 140.115.82.88

基本條件

.Net 原始碼 | ASP.NET News Reader Beta 0.2.9

請參閱

個人資料 | 發表新文章 | 回覆 | 回信 | 轉寄 | 同標題 | 搜尋 | 列印 預覽 直接

重要訊息通知

2007/06/21 由於微軟新聞伺服器移除多數新聞群組 (newsgroup),目前遭移除之群組暫時改為隱藏純瀏覽,若狀況已定案時,將會將隱藏中的群組重新調整。[討論]