1990-12-01 — Page 27

華僑日報 All

(27)育频 日五十月十年午庚慶夏

報日僑華

variable to be zerd if it is not defined. But it is not always (e) Subroutine

六期星、日一月二十(〇九九一)年九十七國民革中

青教化文日五十月十年午庚腦夏

Computer (9)

true. Therefore it is a good habit to put the initial value for variables

BASIC statement

Parts (a) to (d) may be put in the same program segment.

10 GOSUB 500

199】 中學會考預習專欄:

明德出版社

MILL & DALE PRESS

Programming Exercise

1400 DATA "WONG SK", 1. 15. 170.49

write a program for the.P.Ev teacher to do the following jobs:

130

K CHOY

140

120 FOR 11 40 40

READ NAMS(1), SEX$(I), AGE(1), HEIGHT(1), WEIGHT(I)

IP-SEX$(I); = "M" THEN

BOY BOY +1%

ELSE GIRL GIRL: +49

150

IF ALI) 15 THEN OLD OLD

160

AAGE AAGE + ACC(11

"170

AWEIG AWE 16+ WEIGHT([}

(a) (using Jime number 100 to 190) to read, data in suitable

dimensjonen array. NAMS, SEXS, AGE, HEIGHT, WEIGHT,

(b), (Using Fine Aumber 200′ to 290) to count the numbers of boys ant

is in the classe

Boering. The-

number by 3338cading

500 REM BUBBLE SORT:

590 RETURN

A P.E teacher a secondary schicol try to use a computer to keep records of 40 students in a class. The fields in each record are int the order NAME SEX, AGE, HEIGHT WEIGHT. He wants to do some statistics on the data. Ho has typed some lines as the program segment..

1010 DATA CHAN STY

1020 DATE "ERENG TW".

"F", 13, 160, 47

165, 51

180 NEXT S

But it is suggest to follow the instructions given by the question. On the other hand, the structure may not be clear if it is all put na, a 1000.

The relationship between flowchart and BASIC.

(a) Séquence

Sige!!

FONDO

Program Segment.

Programming Exercise

Bubble sort

Write a program in BASIC that can do the following jobs. (a) A list of 20 names and marks are inout into

dimensional array.

a two-

(b) The list of names and marks are sorted according to the

decending order of märks..

(c) The sorted list should be printed out.

BASIC program

1c -

INFU "PLEASE INPUT A NUMBER

10

REM. INPUT- OF, MAMES AND--NARKS

20

DIM NAM$ (20)","MARK (20)

30

FOR 1 110 201

40

INPUT NAME OF STUDENT

MANSUI)

50

INPUT "MARK OF SINDENT MARKII)

GO

FRINT

RINE THE SQUARE OF)

AUMBER

70

NEXT

100

REM BODY OF BUBBLE SORT

110

FOR A TO ̊ (19)

120

FOR K 1 TO 20-3

130

140

150-

160

170

180

NEXT

Frantus"

INPUT PLEASE INPU PADIUS OF CIRCLE"!

200

210

220

FOR 1 10, 20: ·

IF RO THEN

230

LE MARK(K) > MARK-(K+1). THEN 170-

NEXT K

TNAMS NAMBIK) } TEMP. = MARK(K)

NÁMSIK) = NAMS(NIT). < MARKOK) = MARK(K+1) NANG(K+1) = TNAMS MARK(K+1) = TEMP,

REM PRINT THE SORTED LIST IN ORDER OF MARK,

PRINT THE SORTED LIST:"

PRINT NAMS(1), MARK(1)

NEXT A

(g). Using Pipe number 300 to 390 to count the number of students

who are older than 13,

(d) (Using line number (400" to 5901 to find the average age and

weight of the class,

((e) (Using line 600 to 690) to find the tallest student in the (b) Unconditional Branching, and Conditional Branching:

class. Output the name and height of the student. Assume no, two students have the same height)

100 REM CA) INPUT: OF DATA

110 DIM NAME(40), SEX$(40), AGE(40), HEIGHT(40),, WEIGHT(40),

120 FOR 1 TO 40

130 READ NAMS(0); SEX$IT), AGE(1), HEIGHT(1), NEIGHT(1)" 140 NEXT

700 RÈM B) COUNT FOR BOYS AND GIRLS

210 · BOY. -. D

220 GIRL = 0

230 FOR TU 40.

240 IF SEX$(1) THEN

BOY ROY 1.

ELSE GIRL GIRL AN

250 NEXT 1.

260 PRINT AT THE NUMBER OF BOYS.

270. PRINT THE NUMBER OF GIRLS

300 HEM 16) TO COUNT STUDENT OLDER THAN

301 VOLD =

32D FON 1.10. 40

330 IF ACT), 15 THEN OLD 2DLD

JAD NEXT!

350 PRINT THE NUMBER, OF STUDENTS OLDER THAN-

400 REM(D) TO FIND AVERAGE AGE, AND AVERAGE WEIGHT

410 AAGE-0

420 AWE LG 0

430, FOR 11 TO 40 M

440

450

46D NEXT

LARGE - MAGE + AGE(1).

AWEIG AWEIG +"WEIGHT(1)

470 AAGE AAGE/401.

480 AWEIG

AWE16/40.

490 PRINT "AVERAGE AGE : ANGE

500 PRINT "AVERAGE WEIGHT AWEIG

600-REM (E) FIND THE TALLEST, STUDENT 610 11

620 FOR J. 2. TO 40

630

IF HEIGHT(1)HEIGHT(J. THEN I

640 EX 3.

650 PRINT "THE TALLEST STUDENT IS" NAM$(1)

660 PRINT "THE HEIGHT IS: REIGHT(D). 670 END

Remarks:

HONG

Students are request to use meaningful variablega hot store the names, AGE for ages, etc.

This important to notice that the data format

and sex ane character strings while the others constants..

11.Lipe 240 may not, he executable, in APPLE le machine.

changed

dato-

240, 1F: SEX$(I)=M THEN BOY BOY + 1.

245 IF SEX$(F) = "F" THEN GIRL + GIRL +

The

IF THEN ELSE is accepted in the HKCĘĆ.

START

Program Segment.

GREA

1 x 3 is the conditional branching, the, branching depends on the dius as the condition. Line 20 is the corresponding BASIC statement.

(2) The flowline after pax 5 is the unconditional branching.

50 is the corresponding BASIC statemen

(c) Selection

(d) Implementation of Counter

NAMS

Lines 210, 220, 310, 410 and 420 are the initialization of Variables The initial value are given so that it is defined when it is used for the first time in later lines. Most students forget to do this. Some of the SASIC interpreter may assume the

Giant Winladustrial Co.

FLAT 7, LDE, KINGSFORD INDUSTRIAL CENTRE

13 PHẢNG PICH FROAD NOWLED 147. NLN.

TEL. 862-759 91||

Auto Office Systoma Çu.

Now Lite Company Gapplius

:80286 中央微處理器: 16MHZ

3MB 高速暫存記憶容量

40 MB

·1.2 MB 5.25吋磁碟機

辦/1駿大章

· 101 M

14吋黑白雙色顯示器

HK$ 6850.00

28 MS);

*如惠龥任何套餐均附送茸編自軬软件

三及可以 HK$1,200 半價選購

Super 5 EP-2400A #TEPH

($2,400).

招生

特價電腦套餐

先進電腦中心

STARE

BASIC statement

NEXT

PUBLIC

雄入門,

006

LOTUS 123

OBASE

WORDSTAR

$250

$395

$495

6405

$485

中文(體曲/情天

兒童電腦興趣班

$466

DBASE PROGRAMMING

ADVÄNGE LOTUS

***BLU

BASIC/COBOL

80286 - 16MHZ Turbo

$595

$595

每月:$155

:每月$195

#$105

$6800

80386SX - 20MHZ

Turbo

$7950

80386- 25/33MHZ DX

$10,500

本中心學生另有折扣)

240-

.250 AND

Discussion:

(a) REM statements should be added whenever appropriate. The job

description of the following program segment is written,

cuctural programming a good practice so not hise to much TO statements. Otherwise you may get lost in the program Statements. Indentation or the program makes it clear that it is a loop.

FOR J TO 19.

FOR

1 TO 20-

是統生物學家市作標本、陳崴研究遺學的.

一些,也成不了英雄,倘不坐牢,刮款若十元的可能性很大。

·野生動物·立了达会,結果如何不清楚,科保護法,是不會因此取消吧? ORDRE KRZLAZARIZERY SUE ME LEWERS 「只拍暮躍,不打老虎,到了今天,只要你滅活成气,簡直打不折不扣 壯」之石。有維見過畫一女救娜的?只就這點而論,咬死幾個人也可底凉了。 有的)中的座石銘,或者成為當地公務員和居民的誡條,拍蒼蠅不會有罪,打的故事。蕭繩有什麼故事?裡化肥法性呢?想出。幸而英國作製戈爾

·打一的趨勢,能管們然會改完人,还要希望他佛宗接代,保護還是要保護她说一的錘是木-不說,連處不到,不到应不足道的

·老虎則須考慮考慮,在這精市況之下,即使力能沖虎,像武松一樣,徒手打死 William Golding 得宁今次講具年文學獎,他寫過一六小說《芳姬人[]》、通 據說人見獅定,會覺得「彰性」,所以獅虎快往入,一幅大印堂:「彩 黑就變爲活究,哪一個國家擁有,把究成爲「國寶」。而老虎現沉濁水管「國,國王、皇帝、實的顶上啊?我就辦到了,樂於高興,還要吻吻世界的乳 5. 可計数,成爲運物,如供像古生代的三葉蟲,純純死光了,忽然發現一封登(Ladontaine )偶然好-則寓言,全是蒼蘭在向螞蟻吹出,,你忙不限 所以「只消蒍施,不打老虎」,可以作為老虎子護區,像馬來西亞等地性一. 前大筆亂作就像說握的:《聖商) 上存者说受,提珽統醫生,亞倫以報此 六一定是蒼蠅,但蒼蠅無疑是浩然罪犯,再用背蠅容輕殖,全世界多到不 少,雖使寫的吗,慣用動物做主角,大多是而,椒、威,很少川會懂,拉 人,只要毆兩個,就會阿起來。蒼蠅害人,一場愛烈拉,死人上百上千、活 ,有人默文章,秋天地之大,愈難之女,都可以拿來做題目,根摟物必有 著的人受鶩,劉捏緊挨友商之苦,打一針防变出即可安然,雖然當時的傳染媒 「用」的原則,這話也不算城,不洞設是逗麼說,幸蒼蠅作題阡做文章的畢竟 SEZAEVIESUDEERE LAND

少脆骨,把那不地很容易殺手,這件事終於在台灣神了答案,台灣的酒專賣 例如一虎骨酒,據說是強身之物。但一向懷疑,那麼多的「虎骨酒」,要多 ,再說比難傷人,還是有用之扔,例如皮皮椅,虎皮地估,有特殊用途 -

打・城

北白天光圖者獲出版,將就著《過年的心路》

Ma

1985 - 莫迪利阿炮;藝得去容館

程冷海演;香港文化中心大廣場 Jatja AIZREN 14 FYEKET

香港政楦案虧的介紹·香港

博物铪;下午三時

上述節目・全部免费

The structure make it easy

between 120 and 170 is the

Inner loop, and line teleaf110eacji 180: Ys "the outer loop. No inter-crossing of loopwill b

But it is aly true form

Arst versions of BASIC ONESTOG for ALE I user unless a set of machine code 15 kéred 13 ou ore requested to use structural programming style when answering questions in the HKCEE.

students using the Commodore PC-10 model of computer. Lines 140 to 160 can be replaced-by:

140 150

SWAP NAM$(K), NAMS(K+1} } SHAP-MARK(K), MARK{K+1} ====

The SWAP function exchange the lues of two variables However you are suggested to use this function in examination because.ft is not included in the reserved word list announced by the Hong Kong Examination Authority. You are encourage to use a wide varie functions provided by your. machine in the computer laboratory bút not in the examination.

Using, the sorted is! og landent names and marks in {}}} Write a subroutine program mang the algorithm of linear search to look for the-existence of a student and then print his mark and position.

500

510

520

530

REM SUBROUTE LINEAR SEARCH

INPUT "MARIE DEEMENT TO BE SEARCH"; NAS ·

FOR 1 TO

HEA NASZA NAMS (1) THEN 580

PRICE DAME OF STUDENT" NAME 1, 10)

550BRIN 'MARK" - MARK CI

PRINT "POSITION":

GOTO 660

570

580

NEXT I

$590.

660

END

PRINT THE STUDENT IS NOT IN THE LISTO

END

Freecom 786/12 Computas

Standard

Basic

500.00

3,872.03

- ecset cry 120

wall state(18Hz).

dpium ioio pod

(Spelut, 1 Pagjižal and

Game part”.

101-keys, enhanced keyboard

LED Display

One year full warranty

freplacement).

Exacom 286/17400

7,227:00

--Buster unit" 16" Duaj Monitor, 4

· Dual Card 2 40h 28ms AT Bus

Hajodiak në adapte

Freecom 206/12-ADY.

12,112.00

10,796,00

199] 中學會考預習專欄

明德出版社- MILL & DALE PRESS

Economics (9)

財團徵

ALAI

不交吉樓舖交吉亦 全幢或大批更佳 無需 價合成交 港九均金

照榮投資公

7 8 9 3 0 2 3 (#

九龍旺角亞皆老街 40-46 號利纂大廈7:

博覽旅遊

有限公司 No. 350090

|丸就尖沙咀星光行1426-1428室

735185) 7351031

中西方大道中(京華酒欉樓上)

· Basie talk • ug” VGA Morištar & VGA CECA - 4ON 20m AT Qua Hardtak w/ adaptor

5217205 5268105

TEL ROZVIN96YRA

dvance 九龍旺角彌敦道691 號永如大厦3F Computer

Tel:3961970

HKD .6,770,00

V POWER

VS-POWER 80286 12MHz

-IM RAM ON BOARD

-AT I/O Card

-1.2M Floppy Disk Drive

Marksdata Computer Limited

Tel: 751-7863

Fax: 751-7769

Unit 10, 9/F Kingsford Ind. Ctr., 12 Wang Hot Ad,, Kowloon Bay

電腦證書課程

全港最大電腦訓練中心,面積 2500呎 保證每人一機,免費講義,全部電腦枱

File Programming

· DOS $250/$380

Macro Prognuming AutoCAD HUMMARAT dBase Programming

80286 + 40Mb

$5900

「我知道36號銀行中心50車

SE JA PRADA PRO 2721

ANGIE PREKES 4+4=21012 | KEWAL.)

8907133

3325695 #

4920248 4160806

辘物站浙排137142室

7973021

日本

-1.44M Floppy Disk Drive 40M Hard Disk; (28mb) |- -HDD/FDD Controller Caro -Mini Tower of RT Case

with Power Supply

·各類課搖每星期背有數班 ・学可猫10小時光街練習

Dou

大阪、東京迪士尼

領先蔞腦系統

韓國

七天樂華團

$ 7990

229-3

kotue

80286+兩磁碟機

63900

名古屋、東京、迪士尼 五、七天豪華團 $ 6490

韓國

| 四天:

dBuse

$1200

-101-Keys Keyboard

Symphony

Framework

-14" Paper White Monitor

WordStar

WordPerfect

-Qual Display Card

DacEasy

AutoCAD

兒童興趣班 $200

[鹿兒島、九州五、七、

八豪團

$28

$6490起

py-

撕/倚天中文系統全科

80386 + 40Mb 1242

$10300

北海道、東京·迪士尼· 五、六、七臺華團$7590起

│漢嫌

五天

* One Year Warranty

領先電腦中心

九龍彌款道46號收成2尺,全浙(山林品

佐敦地概站柯本輕池出口

TEL:7737833 FAX:7237711

|九州、東京、豬

七、八天豪豬園 $6590起

韓國

AR

韓國

JA

A*

X

高麗蠍子有撕公

WIĄTKANE DO 156 NEAR ME AARE KLİN

Tel. 18572891252 TK 55322 ORSAK

Cabin: KARELESSUP 1:1852) 343 3478. 342 60

KOMPUŁ

286/386)

Room 1404 5

Hong Kong Plaza 186-191

Connauglu & W

Hong Kong

m

MacroPro Computer Company

Comments

Approved members can add comments, bookmarks, and private notes.

No comments yet.

Private Research Note

Private notes are available after approval.