Computer Programming (I)

Practice Problems

Oct. 4, 2007

 

1.     Write a program to print out the multiplication table (九九乘法表) without row and column headings.

2.     Add row and column headings to your solution for Problem 2.

3.     Fill in the blank in the following program segment to output 11, 12, 13, 14, …, 20:

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

   cout << _____ << endl;

4.     Fill in the blanks in the following program segment to output 0, 3, 6, 9, …, 27:

for (int i=0; i > ______; i=i-1)

   cout << _____ << endl;

5.     Fill in the blanks in the following program segment to output 0, -1, -2, -3, …, -30:

for (int i=0; _______; i++)

   cout << _____ << endl;

6.     Fill in the blanks in the following program segment to output 1, 4, 7, 10, …, 28:

for (int i= _______; _______; ________)

   cout << 10+3*i << endl;

7.     Fill in the blanks in the following program segment to output 1, 4, 7, 10, …, 28:

for (int i= _______; _______; _______)

   cout << 9-i << endl;

8.     Fill in the blanks in the following program segment to output 74, 65, 56, 47, 38, 29, 20, 11:

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

   cout << _____ << endl;

9.     Fill in the blanks in the following program segment to output 74, 65, 56, 47, 38, 29, 20, 11:

for (int i= _______; _______; ______)

   cout << 3*i+2 << endl;

10. 程式重複以下動作,每次讀入一個整數值,印出其絕對值。當讀入的數是-999時結束程式。

11. 程式重複以下動作,每次讀入一個學生分數,輸出換算出的letter grade。當讀入的數是負數時結束程式。

12. 程式重複以下動作,每次讀入兩個整數,輸出兩數之和當兩數之和是零時結束程式。