宥翎 發問時間: 電腦與網際網路程式設計 · 2 0 年前

BASIC 或 C 或 Pseudo code 寫出如下程式

用程式語言如 BASIC 或 C 或 Pseudo code 寫出如下程式, 印出結果

sum=1+2+3+…..+100 (即印出 sum 值)

product=1*2*3*….*10 (即印出 product 值)

及99*法表印出如下

2*1=2

2*2=4

.

.

2*9=18

3*1=3

3*2=6

..

3*9=27

4*1=4

.

9*9=81

~作業參考,謝。

1 個解答

評分
  • 匿名使用者
    2 0 年前
    最佳解答

    //sum(By C++)

    #include <iostream>

    using namespace std;

    int main(void)

    {

    int sum=0;

    for (int i=1;i<101;i++)

    sum+=i;

    cout<<sum;

    getchar();

    }

    //-----------------------------------------------

    //product (By C++)

    #include <iostream>

    using namespace std;

    int main(void)

    {

    int product=1;

    for (int i=1;i<11;i++)

    product*=i;

    cout<<product;

    getchar();

    }

    //-----------------------------------------------

    //99 (By C++)

    #include <iostream>

    using namespace std;

    int main(void)

    {

    int product=1;

    for (int i=2;i<10;i++)

    for (int j=1;j<10;j++)

    cout<<i<<"*"<<j<<"="<<i*j<<endl;

    getchar();

    }

    //--------------------------

    //Sum (By VB)

    Dim i As Integer, sum As Integer

    sum = 0

    For i = 1 To 100

    sum = sum + i

    Next

    Print sum

    //--------------------------

    //product (By VB)

    Dim i As Integer, product As Long

    product = 1

    For i = 1 To 10

    product = product * i

    Next

    Print product

    //--------------------------

    //99 (By VB)

    Dim i As Integer, j As Long

    For i = 2 To 9

    For j = 1 To 9

    Print i & "*" & j & "=" & i + j

    Next

    Next

還有問題?馬上發問,尋求解答。