Вы находитесь на странице: 1из 4

Suggested Solutions to 2001 HKCEE Computer Studies Paper I Sections B & C (C Version)

6. Line Number Program Statement


100 scanf("%s", fn); 1
130 MaxScore = -1; 1
160 while ( !feof(f) ) 1
180 fscanf(f, "%s%d%d", Num, &Test1, &Test2); 2
190 Score = (double) (Test1 + Test2) / 2; 1
200 if ( Score > MaxScore ) 1
215/225 strcpy(MaxNum, Num); 2
240 Sum = Sum + Score; 1
Notes:
1. For line 130, zero or any negative value can be assigned to MaxScore.
2. The line ‘strcpy(MaxNum, Num);’ can be either inserted between lines 210 and 220 or between
lines 220 and 230.

7. Step 1 lines 40 - 50 1
Step 2 line 60 1
Step 3 line 70 1
Step 4 lines 80, 90 and 150 1
Step 5 line 100 1
Step 6 line 110 1
Step 7 line 120 1
Step 8 lines 130 – 140 1
Step 9 line 160 0.
Step 10 lines 170 – 180 5
Step 11 line 190 0.
10 #include <stdio.h> 5
1
20 int main()
30 {
40 int dena, remdr;
50 char newnum[80], bina[80];

60 scanf("%d", &dena);
70 strcpy(bina, "");
80 while ( dena > 1 )
90 {
100 remdr = dena % 2;
110 dena = dena / 2;
120 sprintf(newnum, "%d", remdr);
130 strcat(newnum, bina);
140 strcpy(bina, newnum);
150 }
160 sprintf(newnum, "%d", dena);
170 strcat(newnum, bina);
180 strcpy(bina, newnum);
190 printf("%s\n", bina);
200 return 0;
210 }

8. (a) f=0 e = 15 m=7 1


f=0 e=6 m=7 1
f=0 e=6 m=3 0.
f=4 e=6 m=3 5
f=4 e=6 m=5 0.
f=4 e=6 m=5 5
0.
5
0.
5

2001-CE-COMP STUD 1B & C-1 (C Version)


(b) (i) if ( list[m] == t ) or if ( list[m] == t ) 4
flag = true; flag = true;
else else
if ( list[m] < t ) if ( list[m] > t )
e = m - 1; f = m + 1;
else else
f = m + 1; e = m - 1;

(ii) -1 1

(c) Binary search 1

2001-CE-COMP STUD 1B & C-2 (C Version)


9. (a) void Init(int* n) 1
{
int i;

printf("Number of candidates: "); 1


scanf("%d", n);
for ( i = 1; i <= *n; i++ ) 1
vote[i] = 0;
}

(b) void CountBallots(int n)


{
int ballot;

do
{
printf("Candidate number (enter 0 to stop data entry): "); 1
scanf("%d", &ballot);
if ( ballot > 0 && ballot <= n ) 1
vote[ballot] += 1; 1
}
while ( ballot != 0 ); 1
}

(c) void ShowChart(int n)


{
int i, j;

for ( i = 1; i <= n; i++ ) 1


{
printf("Candidate %d |", i); 1
for ( j = 1; j <= vote[i]; j++ ) 1
printf("*");
printf("\n");
}
}

10. (a) arrange the icons by usage frequency 2


arrange the icons by functional group
(any 1 valid answer)

(b) Advantage: can control even at a distance or table space is not needed 4
Disadvantage: cannot control a device when a room is very noisy or when Sunny has a cold that causes
his voice changes.

(c) 1. authentication / security problems 2


2. He may not know the current status of a device before turning it ON/OFF. This may cause
hazardous consequence.

(d) User id, device number, on/off record 2


(any 2 valid items)

(e) Unauthorized people may know Apple’s activities via intruding the Internet 2

2001-CE-COMP STUD 1B & C-3 (C Version)


(f) For each remote control request
check if the corresponding device is turned on locally
if yes, request failed
else fulfill the request

For each local request


fulfill the request

Effective communications:

Relevance 0 / 1 /2

Language/Style 0/1/2
correct and
appropriate

0/1/2/3/4

2001-CE-COMP STUD 1B & C-4 (C Version)

Вам также может понравиться