Yahoo奇摩知識+將於 2021 年 5 月 4 日 (美國東部時間) 終止服務。自 2021 年 4 月 20 日 (美國東部時間) 起,Yahoo奇摩知識+服務將會轉為唯讀模式。其他Yahoo奇摩產品與服務或您的Yahoo奇摩帳號都不會受影響。如需關於Yahoo奇摩知識+ 停止服務以及下載您個人資料的資訊,請參閱說明網頁。
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