Suggested Solutions to 2004 HKCEE Computer Studies Paper I Sections B & C (C Version) 6.
Line Number 310 330 380 420 430 440 450 475 485
7.
(a)
(b)
Program Statement strncpy(classno, data[count] + 3, 2); if ( strcmp(class, inpclass) == 0 && strcmp(classno, inpno) == 0 ) if ( position != -1 ) sprintf(data[position], "%s %s %s\n", inpclass, inpno, newno); datafile = fopen("telist.txt", "w"); for ( i = 0; i < count; i++ ) fprintf(datafile, "%s", data[i]); if ( position == -1 ) else
(i)
ONE
(ii)
BAR
Input the encrypted text into the program. or Modify the code segment as follows: Original version tmp = (int) InStr[i] + shift; if ( tmp > 90 ) tmp = tmp - 26;
(c)
(d)
8.
A B C D E
tmp = (int) InStr[i] - shift; if ( tmp < 65 ) tmp = tmp + 26;
FILE* filename strlen(InStr) Freq[InStr[i] – ‘A’] + 1 Freq[c] > Freq[max]
Letter ‘E’ is not the only most frequent letter because • there may be more than 1 highest frequent letter • the passage contains too many abbreviations or special terms • the passage is not long enough (any two; other reasonable answers accepted)
#include <stdio.h> int main() { int i, n; float f, result;
}
Modified version
i = 1; result = 0.0; scanf("%d", &n); while ( i <= n ) { scanf("%f", &f); if ( i != 1 && i != n ) result += 2.0 * f; else result += f; i++; } result /= 2.0; printf("%f\n", result);
2004-CE-COMP STUD 1B & C-1 (C Version)
9.
(a)
void RemoveSp() { int i, j;
} (b)
j = 0; for ( i = 0; i < strlen(inp); i++ ) if ( inp[i] != ' ' ) { nospace[j] = inp[i]; nospace[j + 1] = '\0'; j++; }
void Upper() { int i; for ( i = 0; i < strlen(nospace); i++ ) if ( nospace[i] >= 'a' && nospace[i] <= 'z' ) nospace[i] = nospace[i] - 'a' + 'A'; }
(c)
void Test(int* result) { int i;
} 10.
(a)
for ( i = 0; i < strlen(nospace) / 2; i++ ) if ( nospace[i] != nospace[strlen(nospace) - 1 - i] ) *result = false;
(i)
SID or student number
(ii)
It can handle leading zero(s).
(iii)
It can save storage space. It can save time on data entry. It can reduce errors on data entry. The data in the system will not be affected by the change of subject names. (any two)
(b)
It is flexible to increase more subjects. OR: It is easy to create queries for subject information.
(c)
(i) (ii)
It cannot eliminate all typing errors. (Not a complete solution) It spends more time on data entry process. (More resources needed) Step 1: Step 2: Step 3:
(d) (e)
1. 2.
Eliminate unnecessary entries (Name, Sex, Email address). In addition, create small boxes for students to fill in to represent the data they input and students are no longer to write alphabets on the sheet. Put all the registration sheets on an optical mark reader (OMR) machine to scan and collect the data
Invalid data (e.g. subject code) are marked on the sheet. Some important data (e.g. student number) are left empty.
He should not publish students’ addresses and contact telephone numbers so as to preserve the data privacy. He should arrange students to check their personal data privately. Or he can just show the SID instead of name for students to check their own information.
2004-CE-COMP STUD 1B & C-2 (C Version)
Effective communications: Relevance
0 / 1 /2
Language/Style correct and appropriate
0/1/2
0/1/2/3/4
2004-CE-COMP STUD 1B & C-3 (C Version)