隨堂小考

11/30/2004

#include <stdio.h>

main()

{

        // modify declarations as you see fit

        int a[10] = { 3, 20, 7, -5, 9, 10, 1, 32, 100, -2};

        int i;

        // add your code here

}

白紙答題卷做下面題目:

1.         Compute and print out the sum of all positive a[i]. (計算並印出所有正的a[i]之和。)

2.         Print the number of a[i]’s, where a[i] is positive and divisible by 5. (印出array a中所有不但是正數且為5的倍數的a[i]之個數。)

 

黃紙答題卷做下面題目:

1.         Compute and print out the sum of a[i] for all odd i. (計算並印出所有奇數ia[i]之和。)

2.         Print the number of a[i]’s, where a[i] is between –10.5 and +20.5. (印出array a中介於–10.5+20.5a[i]之個數。)