wan asked in 電腦與網際網路程式設計 · 2 decades ago

急!!幫幫我~最好能在今天前@”@

請問要怎麼用VC寫出下面的九九乘法表

9 8 7 6 5 4 3 2 1

-----------------------------------------------

9| 81 72 63 54 45 36 27 18 9

8| 72 64 56 48 40 32 24 16

7| 63 56 49 42 35 28 21

6| 54 48 42 36 60 24

5| 45 40 35 30 25

4| 36 32 28 24

3| 27 24 21

2| 18 16

1| 9

這個乘法表有四種三角形的變化,誰能幫幫我@@"

因為我想了很久想不出來,腦袋都快打結了,就是轉不過去!!

Update:

#include<iostream>

#include<cstdlib>

using namespace std;

int main(void)

{

int i=9,j;

cout << "x| 9 8 7 6 5 4 3 2 1\n";

cout << "-+-----------------------------------------\n";

while(i>=1)

{

Update 2:

j=9;

cout<<i<<'|';

while(j>=i)

{

cout.width(3);

cout<<i*j;

j--;

}

i--;

cout<<endl;

}

system("pause");

return 0;

}

貼不下去只好貼二次~這個是原程式!!

Update 3:

回答超級淡的問題...

我不是在上課的時候發問的喔!

我是在家想破頭想不出來才發問的= =+

2 Answers

Rating
  • 2 decades ago
    Favorite Answer

    you are close enough, only minor modification will do it. Here is the source code:

    #include<iostream>

    #include<cstdlib>

    using namespace std;

    int main(void)

    {

    int i=9,level=1,j;

    cout << "x| 9 8 7 6 5 4 3 2 1\n";

    cout << "-+-----------------------------------------\n";

    while(i>=1)

    {

    cout<<i<<'|';

    for (j=9; j>=level; j--) {cout.width(3); cout<<i*j;}

    level++;

    cout<<endl;

    i--;

    }

    system("pause");

    return 0;

    }

  • 2 decades ago

    請你把題目打清楚!都亂調ㄌ!謝謝!有是密我!我的即時通是:call_520530f

Still have questions? Get your answers by asking now.