close

99乘法.png 

#include <stdio.h>
#include <stdlib.h>

int main()
{
    int num1,num2;
    for(num1=1;num1<=9;num1++)
    {
       for(num2=1;num2<=9;num2++)
       {
          printf("%d * %d = %d \t",num1,num2,num1*num2);
       }
    }
    printf("\n\n");
    system("PAUSE");
}

99乘法2.png 

int num1,num2;       宣告num1,num2為可變數

for(num1=1;num1<=9;num1++){}     做一個迴圈,將num1的範圍定在1~大於等於9

for(num2=1;num2<=9;num2++){}     在num1的迴圈裡面在做一個迴圈num2,範圍也是定在1~大於等於9

printf("%d * %d = %d \t",num1,num2,num1*num2);   以%d格式化字元輸出num1,num2的值

 

num1*num2 => num1 X num3  

迴圈:num1:   1   2   3   4   5   6   7   8   9

                          兩個相乘

迴圈:num2:   1   2   3   4   5   6   7   8   9

 

%d為格式化字元,輸出十進位數

\n與\t為跳脫字元, \n 為換行, \t 為水平跳格 

 

*以上只是個人學習經驗....請參考書本教學及範例..

arrow
arrow
    全站熱搜
    創作者介紹
    創作者 Victor.Li 的頭像
    Victor.Li

    編號:N49817024

    Victor.Li 發表在 痞客邦 留言(1) 人氣()