Page 1

Τ.Ε.Ι. ΛΑΜΙΑ∑ ∑ΧΟΛΗ ΤΕΧΝΟΛΟΓΙΚΩΝ ΕΦΑΡΜΟΓΩΝ ΤΜΗΜΑ ΠΛΗΡΟΦΟΡΙΚΗ∑ & ΤΕΧΝΟΛΟΓΙΑ∑ Η/Υ

∆ΟΜΗΜΕΝΟΣ ΠΡΟΓΡΑΜΜΑΤΙΣΜΟΣ ΓΛΩ∑∑Α PASCAL (ΕΡΓΑ∑ΤΗΡΙΟ)

Αθανάσιος Ε. Κουτσονικόλας Λαμία 2001


ΠΡΟΛΟΓΟΣ Οι σημειώσεις αυτές γράφτηκαν για να χρησιμοποιηθούν ως διδακτικό βοήθημα στο Εργαστηριακό μέρος του μαθήματος ‘Δομημένος Προγραμματισμός’, που διδάσκεται στο πρώτο εξάμηνο σπουδών του Τμήματος Πληροφορικής & Τεχνολογίας Η/Υ του Τ.Ε.Ι. Λαμίας. Δομημένα προγράμματα μπορεί να συντάξει κανείς σε οποιαδήποτε από τις σύγχρονες γλώσσες προγραμματισμού. Επιλέχθηκε η γλώσσα προγραμματισμού Pascal, για την γνωριμία των σπουδαστών με τις Αρχές και τις Τεχνικές του Δομημένου Προγραμματισμού, διότι ακριβώς λόγω του σχεδιασμού και των δυνατοτήτων της καθίσταται ιδανική για τον σκοπό αυτό. Άλλωστε αυτός ήταν ένας από τους σκοπούς του Niklaus Wirth, όταν στις αρχές της δεκαετίας του 1970 σχεδίασε την γλώσσα Pascal. Η ύλη των σημειώσεων έχει γραφεί υπό μορφή Ασκήσεων και καταβλήθηκε προσπάθεια ώστε η κάθε Άσκηση να καλύπτει ένα γνωστικό αντικείμενο. Προϋποτίθεται, βέβαια, ότι οι σπουδαστές έχουν προηγουμένως διδαχθεί και κατανοήσει την αντίστοιχη θεωρία και κατόπιν έρχονται στο εργαστήριο για την πρακτική εφαρμογή των όσον έμαθαν. Πάντως, στην αρχή κάθε Άσκησης υπάρχει σε συνοπτική μορφή η θεωρία που απαιτείται για την επίλυση των ασκήσεων. Θα ήταν ουτοπία, να νομίσουμε ότι οι σημειώσεις αυτές δεν έχουν λάθη και δεν χρήζουν βελτιώσεων. Για το λόγο αυτό, διορθώσεις λαθών και προτάσεις βελτίωσης, είναι ευπρόσδεκτες. Λαμία, Ιανουάριος 2001 Αθ. Ε. Κουτσονικόλας


1

ǹȈȀǾȈǾ 1

ȉȠ ȆİȡȚȕȐȜȜȠȞ IJȘȢ Turbo Pascal 1.1 ǼȚıĮȖȦȖȒ Ǿ įȚĮįȚțĮıȓĮ ȖȚĮ IJȘȞ ȣȜȠʌȠȓȘıȘ İȞȩȢ ʌȡȠȖȡȐȝȝĮIJȠȢ, ıİ ȝȓĮ ȖȜȫııĮ ʌȡȠȖȡĮȝȝĮIJȚıȝȠȪ, İȓȞĮȚ Ș ĮțȩȜȠȣșȘ: Į) īȡȐijȠȣȝİ IJȠ ʌȡȩȖȡĮȝȝĮ ȤȡȘıȚȝȠʌȠȚȫȞIJĮȢ ȑȞĮȞ ĮʌȜȩ ıȣȞIJȐțIJȘ țİȚȝȑȞȠȣ (editor), ȕ) ȂİIJĮijȡȐȗȠȣȝİ IJȠ ʌȡȩȖȡĮȝȝĮ Įʌȩ IJȘȞ ȖȜȫııĮ ʌȡȠȖȡĮȝȝĮIJȚıȝȠȪ ıİ ȖȜȫııĮ ȝȘȤĮȞȒȢ, Ȗ) ǼțIJİȜȠȪȝİ IJȠ ʌȡȩȖȡĮȝȝĮ. Ǿ Turbo Pascal İȓȞĮȚ ȑȞĮ ȠȜȠțȜȘȡȦȝȑȞȠ ʌİȡȚȕȐȜȜȠȞ ĮȞȐʌIJȣȟȘȢ ʌȡȠȖȡĮȝȝȐIJȦȞ Pascal. ǻȘȜĮįȒ ʌȡȠıijȑȡİȚ ıIJȠȞ ʌȡȠȖȡĮȝȝĮIJȚıIJȒ ȑȞĮ ʌİȡȚȕȐȜȜȠȞ ȖȚĮ IJȠ ȖȡȐȥȚȝȠ, IJȘȞ ȝİIJȐijȡĮıȘ țĮȚ IJȘȞ İțIJȑȜİıȘ ʌȡȠȖȡĮȝȝȐIJȦȞ Pascal. 1.2 Ǿ İțțȓȞȘıȘ - ȉĮ ȝİȞȠȪ Ǿ Turbo Pascal İȓȞĮȚ İȖțĮIJİıIJȘȝȑȞȘ ıIJȠȞ țĮIJȐȜȠȖȠ TP IJȠȣ ıțȜȘȡȠȪ įȓıțȠȣ IJȠȣ Ǿ/Ȋ. ǹȞĮȜȩȖȦȢ IJȠȣ Ǿ/Ȋ ʌȠȣ ȤȡȘıȚȝȠʌȠȚİȓIJĮȚ ıIJȠ İȡȖĮıIJȒȡȚȠ, įȚĮijȑȡİȚ țĮȚ Ș įȚĮįȚțĮıȓĮ İțțȓȞȘıȘȢ IJȘȢ Turbo Pascal. ǹȞ İțțȚȞȒıȠȣȝİ IJȠȞ Ǿ/Ȋ ıİ ʌİȡȚȕȐȜȜȠȞ MSDOS, IJȩIJİ șĮ ʌȡȑʌİȚ ȞĮ ȝİIJĮȕȠȪȝİ ıIJȠȞ țĮIJȐȜȠȖȠ BIN ʌȠȣ İȓȞĮȚ ȣʌȠțĮIJȐȜȠȖȠȢ IJȠȣ TP țĮȚ ȞĮ ʌȜȘțIJȡȠȜȠȖȒıȠȣȝİ TURBO. ǹȞ İțțȚȞȒıȠȣȝİ IJȠȞ Ǿ/Ȋ ıİ ʌİȡȚȕȐȜȜȠȞ Windows Ȓ Windows NT, IJȩIJİ șĮ ʌȡȑʌİȚ ȞĮ įȘȝȚȠȣȡȖȒıȠȣȝİ ȝȓĮ ıȣȞIJȩȝİȣıȘ (shortcut) ıIJȘȞ İʌȚijȐȞİȚĮ İȡȖĮıȓĮȢ ʌȠȣ ȞĮ ĮȞĮijȑȡİIJĮȚ ıIJȠ ĮȡȤİȓȠ TURBO.EXE ʌȠȣ ȕȡȓıțİIJĮȚ ıIJȠȞ ȣʌȠțĮIJȐȜȠȖȠ BIN IJȠȣ țĮIJĮȜȩȖȠȣ TP. ǹȣIJȒ Ș įȚĮįȚțĮıȓĮ Įȡțİȓ ȞĮ ȖȓȞİȚ ȝȩȞȠ ȝȓĮ ijȠȡȐ, IJȘȞ ʌȡȫIJȘ, IJȚȢ İʌȩȝİȞİȢ ijȠȡȑȢ ĮȞ Ƞ ȓįȚȠȢ ȤȡȒıIJȘȢ ȤȡȘıȚȝȠʌȠȚȒıİȚ IJȠȞ ȓįȚȠ Ǿ/Ȋ țĮȚ įȫıİȚ IJĮ ȓįȚĮ username țĮȚ password (ĮȞ ĮʌĮȚIJİȓIJĮȚ), Ș ıȣȞIJȩȝİȣıȘ șĮ ȣʌȐȡȤİȚ ıIJȘȞ İʌȚijȐȞİȚĮ İȡȖĮıȓĮȢ. ǻȚʌȜȠʌĮIJȫȞIJĮȢ ȝİ IJȠ ʌȠȞIJȓțȚ ʌȐȞȦ ıIJȘȞ ıȣȞIJȩȝİȣıȘ, İțțȚȞȠȪȝİ IJȘȞ Turbo Pascal. ȅʌȠȚȠȞįȒʌȠIJİ Įʌȩ IJȠȣȢ ʌĮȡĮʌȐȞȦ IJȡȩʌȠȣȢ ȤȡȘıȚȝȠʌȠȚȒıȠȣȝİ, ıȤİįȩȞ ĮȝȑıȦȢ İȝijĮȞȓȗİIJĮȚ ıIJȘȞ ȠșȩȞȘ ȝĮȢ IJȠ ʌİȡȚȕȐȜȜȠȞ IJȘȢ Turbo Pascal, ȩʌȦȢ ijĮȓȞİIJĮȚ ıIJȠ ȈȤȒȝĮ 1.1, IJȠ ȠʌȠȓȠ ĮʌȠIJİȜİȓIJĮȚ Įʌȩ IJĮ ʌĮȡĮțȐIJȦ ȝȑȡȘ:. x x x

ȉȘȞ ȖȡĮȝȝȒ IJȦȞ ȝİȞȠȪ. ȉȠȞ ıȣȞIJȐțIJȘ țİȚȝȑȞȠȣ (ʌĮȡȐșȣȡȠ Edit) ȩʌȠȣ ȖȓȞİIJĮȚ Ș ıȣȖȖȡĮijȒ/įȚȩȡșȦıȘ IJȠȣ ʌȡȠȖȡȐȝȝĮIJȠȢ. Ǿ ȖȡĮȝȝȒ IJȦȞ ȕȠȘșȘIJȚțȫȞ ʌȜȒțIJȡȦȞ (Function Keys).

Ǿ ȖȡĮȝȝȒ IJȦȞ ȝİȞȠȪ İȝijĮȞȓȗİIJĮȚ ıIJȘȞ țȠȡȣijȒ IJȘȢ ȠșȩȞȘȢ țĮȚ ȠȚ İʌȚȜȠȖȑȢ IJȘȢ įȚĮijȑȡȠȣȞ Įʌȩ ȑțįȠıȘ ıİ ȑțįȠıȘ IJȘȢ ȉurbo Pascal ʌ.Ȥ. ȖȚĮ IJȘȞ ȑțįȠıȘ Turbo Pascal 7, ĮȣIJȑȢ ȠȚ İʌȚȜȠȖȑȢ İȓȞĮȚ ȠȚ File, Edit, Search, Run, Compile, Debug, Options, Window țĮȚ Help. ȉȠ ıȪıIJȘȝĮ IJȦȞ ȝİȞȠȪ IJȘȢ Turbo Pascal, İȓȞĮȚ ȑȞĮ ıȪıIJȘȝĮ ʌIJȣııȩȝİȞȦȞ ȝİȞȠȪ (pull-down menus). ǻȘȜĮįȒ ȩIJĮȞ İʌȚȜȑȟȠȣȝİ ȝȚĮ İʌȚȜȠȖȒ Įʌȩ IJȠ ȕĮıȚțȩ ȝİȞȠȪ țĮȚ ʌĮIJȒıȠȣȝİ ENTER, ĮȞȠȓȖİȚ ȑȞĮ ʌĮȡȐșȣȡȠ ȝİ IJȚȢ įȚĮșȑıȚȝİȢ ȣʌȠİʌȚȜȠȖȑȢ ʌȠȣ ȝʌȠȡȠȪȝİ ȞĮ țȐȞȠȣȝİ. ȊʌȐȡȤȠȣȞ ĮȡțİIJȠȓ IJȡȩʌȠȚ ȖȚĮ ȞĮ įȚĮȜȑȟȠȣȝİ ȝȚĮ İʌȚȜȠȖȒ Įʌȩ IJȠ țȪȡȚȠ ȝİȞȠȪ, ȤȡȘıȚȝȠʌȠȚȫȞIJĮȢ IJȠ ʌȜȘțIJȡȠȜȩȖȚȠ Ȓ IJȠ ʌȠȞIJȓțȚ (mouse) ĮȞ įȚĮșȑIJȠȣȝİ. ȆȚȑȗȠȞIJĮȢ IJȠ ʌȜȒțIJȡȠ F10 ijȦIJȓȗİIJĮȚ (İʌȚȜȑȖİIJĮȚ) țȐʌȠȚĮ Įʌȩ IJȚȢ İʌȚȜȠȖȑȢ IJȠȣ ȝİȞȠȪ, ıIJȘ ıȣȞȑȤİȚĮ ȝİIJĮțȚȞȫȞIJĮȢ IJȘ ijȦIJİȚȞȒ ȜȦȡȓįĮ ȝİ IJĮ ʌȜȒțIJȡĮ Å (ĮȡȚıIJİȡȩ ȕȑȜȠȢ) țĮȚ Æ (įİȟȚȩ ȕȑȜȠȢ). ȝʌȠȡȠȪȝİ ȞĮ įȚĮȜȑȟȠȣȝİ IJȘȞ İʌȚȜȠȖȒ ʌȠȣ șȑȜȠȣȝİ ʌĮIJȫȞIJĮȢ Enter. ȂȚĮ ȐȜȜȘ ȝȑșȠįȠȢ İʌȚȜȠȖȒȢ Įʌȩ IJȠ ʌȜȘțIJȡȠȜȩȖȚȠ, İȓȞĮȚ ȞĮ ʌĮIJȒıȠȣȝİ ĮʌȜȐ IJȠ F10 țĮȚ ȝİIJȐ IJȠ ĮȡȤȚțȩ ȖȡȐȝȝĮ IJȘȢ İʌȚȜȠȖȒȢ (ȖȚĮ ʌĮȡȐįİȚȖȝĮ, F ȖȚĮ IJȘȞ İʌȚȜȠȖȒ File, E ȖȚĮ IJȘȞ İʌȚȜȠȖȒ Edit). ȂȚĮ IJȡȓIJȘ ȝȑșȠįȠȢ İʌȚȜȠȖȒȢ Įʌȩ IJȠ ʌȜȘțIJȡȠȜȩȖȚȠ İȓȞĮȚ, ȞĮ ʌĮIJȒıȠȣȝİ IJĮȣIJȩȤȡȠȞĮ IJȠ ʌȜȒțIJȡȠ Alt țĮȚ IJȠ ʌȡȫIJȠ ȖȡȐȝȝĮ IJȘȢ İʌȚȜȠȖȒȢ IJȠȣ ȕĮıȚțȠȪ ȝİȞȠȪ ʌȠȣ İʌȚșȣȝȠȪȝİ.


2

ǹȈȀǾȈǾ 1

ȈIJȘȞ IJİȜİȣIJĮȓĮ ȖȡĮȝȝȒ IJȘȢ ȠșȩȞȘȢ, İȝijĮȞȓȗİIJĮȚ ȑȞĮȢ țĮIJȐȜȠȖȠȢ ȝİ IJĮ ȜİȖȩȝİȞĮ ȜİȚIJȠȣȡȖȚțȐ ʌȜȒțIJȡĮ (Function Keys), IJĮ ȠʌȠȓĮ İȓȞĮȚ ʌȜȒțIJȡĮ ʌȠȣ ȝĮȢ ʌĮȡȑȤȠȣȞ ȖȡȒȖȠȡȘ ʌȡȩıȕĮıȘ ıİ ıȣȤȞȐ ȤȡȘıȚȝȠʌȠȚȠȪȝİȞİȢ ȜİȚIJȠȣȡȖȓİȢ, ijȣıȚțȐ IJȚȢ ȜİȚIJȠȣȡȖȓİȢ ĮȣIJȑȢ ȝʌȠȡȠȪȝİ ȞĮ IJȚȢ İțIJİȜȑıȠȣȝİ țĮȚ ȝȑıĮ Įʌȩ IJȠ ȝİȞȠȪ. ȉĮ ȜİȚIJȠȣȡȖȚțȐ ʌȜȒțIJȡĮ ĮȜȜȐȗȠȣȞ țȐșİ ijȠȡȐ ȖȚĮ ȞĮ IJĮȚȡȚȐȗȠȣȞ ȝİ IJȠ İȞİȡȖȩ ʌĮȡȐșȣȡȠ. ȂʌȠȡȠȪȝİ ȞĮ İʌȚȜȑȟȠȣȝİ ȠʌȠȚĮįȒʌȠIJİ ȜİȚIJȠȣȡȖȓĮ ȜİȚIJȠȣȡȖȚțȠȪ ʌȜȒțIJȡȠȣ Įʌȩ ĮȣIJȐ ʌȠȣ İȝijĮȞȓȗȠȞIJĮȚ, ʌĮIJȫȞIJĮȢ IJȠ ıȤİIJȚțȩ ʌȜȒțIJȡȠ (ʌ.Ȥ. IJȠ F2 ȖȚĮ ȞĮ ĮʌȠșȘțİȪıȠȣȝİ IJȠ țİȓȝİȞȠ ʌȠȣ ȕȡȓıțİIJĮȚ ıIJȠ İȞİȡȖȩ ʌĮȡȐșȣȡȠ), Ȓ ʌĮIJȫȞIJĮȢ ȝİ IJȠ ʌȠȞIJȓțȚ ıIJȘȞ İʌȚȜȠȖȒ ʌȠȣ șȑȜȠȣȝİ ȖȚĮ ȞĮ ʌȐȡȠȣȝİ IJȠ ȓįȚȠ ĮʌȠIJȑȜİıȝĮ.

ȈȤȒȝĮ 1.1: Ǿ ȠșȩȞȘ IJȠȣ ʌİȡȚȕȐȜȜȠȞIJȠȢ IJȘȢ Turbo Pascal

ȆĮȡĮțȐIJȦ șĮ ʌȠȪȝİ įȣȠ ȜȩȖȚĮ ȖȚĮ IJȚȢ ʌİȡȚııȩIJİȡȠ ȤȡȘıȚȝȠʌȠȚȠȪȝİȞİȢ İʌȚȜȠȖȑȢ IJȦȞ ȝİȞȠȪ. x

ȉȠ ȝİȞȠȪ File

ǵʌȦȢ ijĮȓȞİIJĮȚ țȚ Įʌȩ IJȠ ȩȞȠȝȐ IJȠȣ, IJȠ ȝİȞȠȪ File ʌİȡȚȜĮȝȕȐȞİȚ IJȚȢ ȜİȚIJȠȣȡȖȓİȢ ȖȚĮ IJȘ įȚĮȤİȓȡȚıȘ IJȦȞ ĮȡȤİȓȦȞ IJȠȣ ʌȘȖĮȓȠȣ țȫįȚțĮ. ǵʌȦȢ ȩȜĮ IJĮ ȝİȞȠȪ, İȓȞĮȚ ʌIJȣııȩȝİȞȠ țĮȚ ȠȚ İʌȚȜȠȖȑȢ IJȠȣ İȝijĮȞȓȗȠȞIJĮȚ țĮIJĮțȩȡȣijĮ. ȂʌȠȡȠȪȝİ ȞĮ įȚĮȜȑȟȠȣȝİ ȝȚĮ İʌȚȜȠȖȒ ȤȡȘıȚȝȠʌȠȚȫȞIJĮȢ IJĮ ʌȜȒțIJȡĮ Ç (ʌȐȞȦ ȕȑȜȠȢ) țĮȚ È (țȐIJȦ ȕȑȜȠȢ) ȖȚĮ ȞĮ IJȘ ijȦIJȓıȠȣȝİ țĮȚ ıIJȘ ıȣȞȑȤİȚĮ ȞĮ ʌĮIJȒıȠȣȝİ IJȠ ENTER. ȅȡȚıȝȑȞİȢ Įʌȩ IJȚȢ İʌȚȜȠȖȑȢ įȚĮșȑIJȠȣȞ țĮȚ ȜİȚIJȠȣȡȖȚțȐ ʌȜȒțIJȡĮ. ǼʌȓıȘȢ ȝʌȠȡȠȪȝİ ȞĮ İʌȚȜȑȟȠȣȝİ țȐʌȠȚĮ İʌȚȜȠȖȒ ȝİ IJȠ ʌȠȞIJȓțȚ. ȆİȡȚȖȡȐijȠȣȝİ ıIJȘ ıȣȞȑȤİȚĮ IJȚȢ İʌȚȜȠȖȑȢ IJȠȣ ȝİȞȠȪ File: Open ...F3 ȂĮȢ İʌȚIJȡȑʌİȚ ȞĮ įȚĮȜȑȟȠȣȝİ ȑȞĮ ĮȡȤİȓȠ Įʌȩ ȝȚĮ ȜȓıIJĮ, IJȠ ȠʌȠȓȠ țĮIJȩʌȚȞ ĮȞȠȓȖİȚ ıIJȠ įȚțȩ IJȠȣ ʌĮȡȐșȣȡȠ. New ǹȞȠȓȖİȚ ȑȞĮ ȐįİȚȠ ʌĮȡȐșȣȡȠ țİȚȝȑȞȠȣ ȝİ ȩȞȠȝĮ NONAME00.PAS. ȂʌȠȡȠȪȝİ ȞĮ ĮȞȠȓȟȠȣȝİ ȝȑȤȡȚ İțĮIJȩ ʌĮȡȩȝȠȚĮ ʌȡȠıȦȡȚȞȐ ʌĮȡȐșȣȡĮ įȚȩȡșȦıȘȢ, IJĮ ȠʌȠȓĮ șĮ ĮȡȚșȝȘșȠȪȞ įȚĮįȠȤȚțȐ ȝȑȤȡȚ IJȠ NONAME99.PAS. ǹȞ șİȜȒıȠȣȝİ ȞĮ ĮʌȠșȘțİȪıȠȣȝİ IJĮ ʌİȡȚİȤȩȝİȞĮ İȞȩȢ IJȑIJȠȚȠȣ ʌĮȡĮșȪȡȠȣ, Ș Turbo Pascal șĮ ȝĮȢ ȗȘIJȒıİȚ ȞĮ įȫıȠȣȝİ ıIJȠ ĮȡȤİȓȠ ȐȜȜȠ ȩȞȠȝĮ.


ȉȠ ȆİȡȚȕȐȜȜȠȞ IJȘȢ Turbo Pascal

3

Save F2 ǹʌȠșȘțİȪİȚ ıIJȠ įȓıțȠ IJȠ ʌİȡȚİȤȩȝİȞȠ IJȠȣ İȞİȡȖȠȪ ʌĮȡĮșȪȡȠȣ. Save As... ǹʌȠșȘțİȪİȚ ıIJȠ įȓıțȠ IJȠ ʌİȡȚİȤȩȝİȞȠ IJȠȣ İȞİȡȖȠȪ ʌĮȡĮșȪȡȠȣ, ĮȜȜȐ ʌȡȠȘȖȠȣȝȑȞȦȢ ȝĮȢ ȗȘIJȐİȚ ȞĮ įȫıȠȣȝİ ȑȞĮ ȞȑȠ ȩȞȠȝĮ ĮȡȤİȓȠȣ. Save all ǹʌȠșȘțİȪİȚ ıIJȠ įȓıțȠ IJĮ ʌİȡȚİȤȩȝİȞĮ ȩȜȦȞ IJȦȞ ʌĮȡĮșȪȡȦȞ ʌȠȣ İȓȞĮȚ ĮȞȠȚțIJȐ İțİȓȞȘ IJȘ ıIJȚȖȝȒ. Change dir.. ȂĮȢ İʌȚIJȡȑʌİȚ ȞĮ ĮȜȜȐȟȠȣȝİ IJȠȞ IJȡȑȤȠȞIJĮ țĮIJȐȜȠȖȠ İȡȖĮıȓĮȢ. Print ǼțIJȣʌȫȞİȚ ȠȜȩțȜȘȡȠ IJȠ ʌİȡȚİȤȩȝİȞȠ IJȠȣ İȞİȡȖȠȪ ʌĮȡĮșȪȡȠȣ. Get info ȂİIJȐ IJȘ ȝİIJĮȖȜȫIJIJȚıȘ İȞȩȢ ʌȡȠȖȡȐȝȝĮIJȠȢ, ʌĮȡȑȤİȚ ʌȜȘȡȠijȠȡȓİȢ ıȤİIJȚțȐ ȝİ IJȠ ĮȡȤİȓȠ ʌȠȣ ȝȩȜȚȢ ȝİIJĮȖȜȦIJIJȓıĮȝİ, ȩʌȦȢ IJȠȞ ĮȡȚșȝȩ IJȦȞ ȖȡĮȝȝȫȞ ʌȠȣ ȝİIJĮȖȜȦIJIJȓıIJȘțĮȞ, IJȠ ȝȑȖİșȠȢ ȝȞȒȝȘȢ ʌȠȣ ȤȡȘıȚȝȠʌȠȚȒșȘțİ ȖȚĮ IJȠȞ țȫįȚțĮ ț.Ȝ.ʌ. DOS shell ȂİIJĮijİȡȩȝĮıIJİ ʌȡȠıȦȡȚȞȐ ıİ ʌİȡȚȕȐȜȜȠȞ DOS, ȩʌȠȣ ȝʌȠȡȠȪȝİ ȞĮ İțIJİȜȑıȠȣȝİ ȠʌȠȚĮįȒʌȠIJİ İȞIJȠȜȒ IJȠȣ DOS. īȚĮ ȞĮ İʌȚıIJȡȑȥȠȣȝİ ıIJȠ ʌİȡȚȕȐȜȜȠȞ IJȘȢ Turbo Pascal, ʌȡȑʌİȚ ȞĮ ʌȜȘțIJȡȠȜȠȖȒıȠȣȝİ EXIT. Exit ALT-X ǼȟİȡȤȩȝĮıIJİ Įʌȩ IJȠ ʌİȡȚȕȐȜȜȠȞ IJȘȢ Turbo Pascal. x

ȉȠ ȂİȞȠȪ Edit

Ǿ Turbo Pascal ȝĮȢ įȓȞİȚ IJȘ įȣȞĮIJȩIJȘIJĮ ȞĮ ȑȤȠȣȝİ IJĮȣIJȩȤȡȠȞĮ ĮȞȠȚȤIJȐ ʌȠȜȜȐ ĮȡȤİȓĮ ʌȘȖĮȓȠȣ țȫįȚțĮ ıİ įȚĮijȠȡİIJȚțȐ ʌĮȡȐșȣȡĮ. Ȃİ IJȚȢ İʌȚȜȠȖȑȢ IJȠȣ ȝİȞȠȪ Edit (ǻȚȩȡșȦıȘ) ȝʌȠȡȠȪȝİ ȞĮ ȝİIJĮijȑȡȠȣȝİ IJȝȒȝĮIJĮ țİȚȝȑȞȠȣ Įʌȩ IJȠ ȑȞĮ ʌĮȡȐșȣȡȠ ıIJȠ ȐȜȜȠ ȝİ IJȘ ȕȠȒșİȚĮ IJȠȣ clipboard (ȘȜİțIJȡȠȞȚțȩ ıȘȝİȚȦȝĮIJȐȡȚȠ), IJȠ ȠʌȠȓȠ İȓȞĮȚ ȝȚĮ ʌİȡȚȠȤȒ ʌȡȠıȦȡȚȞȒȢ ĮʌȠșȒțİȣıȘȢ ıIJȘȞ ȠʌȠȓĮ IJȠʌȠșİIJİȓIJĮȚ IJȠ țİȓȝİȞȠ ʌȠȣ șȑȜȠȣȝİ ȞĮ ȝİIJĮijȑȡȠȣȝİ. DzIJıȚ, ȖȚĮ ʌĮȡȐįİȚȖȝĮ, ȖȚĮ ȞĮ ĮȞIJȚȖȡȐȥȠȣȝİ ȑȞĮ IJȝȒȝĮ țİȚȝȑȞȠȣ Įʌȩ ȑȞĮ ʌĮȡȐșȣȡȠ ı'ȑȞĮ ȐȜȜȠ, șĮ İʌȚȜȑȟȠȣȝİ ʌȡȫIJĮ IJȠ ıȣȖțİțȡȚȝȑȞȠ IJȝȒȝĮ IJȠȣ țİȚȝȑȞȠȣ țĮȚ țĮIJȩʌȚȞ șĮ IJȠ ĮȞIJȚȖȡȐȥȠȣȝİ ıIJȠ clipboard, ȝİ IJȘȞ İʌȚȜȠȖȒ Copy (ĮȞIJȚȖȡĮijȒ). ȂİIJȐ șĮ ʌȐȝİ ıIJȠ ȐȜȜȠ ʌĮȡȐșȣȡȠ țĮȚ ıIJȘ șȑıȘ ȩʌȠȣ șȑȜȠȣȝİ ȞĮ ȝİIJĮijİȡșİȓ IJȠ IJȝȒȝĮ IJȠȣ țİȚȝȑȞȠȣ țĮȚ șĮ ȤȡȘıȚȝȠʌȠȚȒıȠȣȝİ IJȘȞ İʌȚȜȠȖȒ Paste (İʌȚțȩȜȜȘıȘ) ȖȚĮ ȞĮ ʌȡȠıĮȡIJȒıȠȣȝİ IJȠ țİȓȝİȞȠ Įʌȩ IJȠ clipboard. Ǿ İʌȚȜȠȖȒ IJȠȣ IJȝȒȝĮIJȠȢ țİȚȝȑȞȠȣ ȝʌȠȡİȓ ȞĮ ȖȓȞİȚ ȝİ įȚȐijȠȡȠȣȢ IJȡȩʌȠȣȢ. ȋȡȘıȚȝȠʌȠȚȫȞIJĮȢ IJȠ ʌȜȘțIJȡȠȜȩȖȚȠ, IJȠʌȠșİIJȠȪȝİ IJȠ įȡȠȝȑĮ ıIJȘȞ ĮȡȤȒ IJȠȣ IJȝȒȝĮIJȠȢ țĮȚ ʌĮIJȐȝİ IJȠ ıȣȞįȣĮıȝȩ ʌȜȒțIJȡȦȞ Ctrl-K B (įİȢ țĮȚ ȆȓȞĮțĮ 1.1) țĮȚ țĮIJȩʌȚȞ IJȠʌȠșİIJȠȪȝİ IJȠ įȡȠȝȑĮ ıIJȠ IJȑȜȠȢ IJȠȣ IJȝȒȝĮIJȠȢ țĮȚ ʌĮIJȐȝİ Ctrl-K K. īȚĮ IJȘȞ İʌȚȜȠȖȒ ĮʌȜȫȢ ȝȚĮȢ ȜȑȟȘȢ Ȓ ȝȚĮȢ ȝȩȞȠ ȖȡĮȝȝȒȢ ȕȜȑʌİ IJȠȣȢ ıȣȞįȣĮıȝȠȪȢ ʌȜȒțIJȡȦȞ IJȠȣ ȆȓȞĮțĮ 1.1. Ǿ İʌȚȜȠȖȒ İȞȩȢ IJȝȒȝĮIJȠȢ ȝİ IJȠ ʌȠȞIJȓțȚ İȓȞĮȚ ĮıijĮȜȫȢ ʌȚȠ İȪțȠȜȘ. ȉȠʌȠșİIJȠȪȝİ ĮʌȜȫȢ IJȠ įİȓțIJȘ IJȠȣ ʌȠȞIJȚțȚȠȪ ıIJȘȞ ĮȡȤȒ IJȠȣ IJȝȒȝĮIJȠȢ țĮȚ țȡĮIJȫȞIJĮȢ ʌĮIJȘȝȑȞȠ IJȠ ĮȡȚıIJİȡȩ țȠȣȝʌȓ IJȠȣ ʌȠȞIJȚțȚȠȪ ıȑȡȞȠȣȝİ IJȠ įİȓțIJȘ ȝȑȤȡȚ IJȠ IJȑȜȠȢ IJȠȣ IJȝȒȝĮIJȠȢ ʌȠȣ șȑȜȠȣȝİ.

ǹș. Ǽ. ȀȠȣIJıȠȞȚțȩȜĮȢ


4

ǹȈȀǾȈǾ 1

Restore line ȉȘ ȤȡȘıȚȝȠʌȠȚȠȪȝİ ȖȚĮ ȞĮ ĮțȣȡȫȞȠȣȝİ ĮȜȜĮȖȑȢ ʌȠȣ ȑȤȠȣȞ ȖȓȞİȚ ıİ ȝȚĮ ȖȡĮȝȝȒ țİȚȝȑȞȠȣ. Ǿ ĮȜȜĮȖȒ șĮ ȖȓȞİȚ ȝȩȞȠ ıIJȘȞ ʌȚȠ ʌȡȩıijĮIJĮ įȚȠȡșȦȝȑȞȘ ȖȡĮȝȝȒ țİȚȝȑȞȠȣ. Cut Shift-Del ǹʌȠțȩʌIJİȚ ȑȞĮ İʌȚȜİȖȝȑȞȠ IJȝȒȝĮ țİȚȝȑȞȠȣ țĮȚ IJȠ ȝİIJĮijȑȡİȚ ıIJȠ clipboard. ȉȠ IJȝȒȝĮ țİȚȝȑȞȠȣ ʌȠȣ ȑȤİȚ ĮʌȠțȠʌİȓ ȝʌȠȡİȓ IJȫȡĮ ȞĮ ȝİIJĮijİȡșİȓ ıİ ȐȜȜȘ șȑıȘ ıIJȠ țİȓȝİȞȠ IJȡȑȤȠȞ țİȓȝİȞȠ Ȓ ıİ țİȓȝİȞȠ ʌȠȣ ȕȡȓıțİIJĮȚ ıİ ȐȜȜȠ ʌĮȡȐșȣȡȠ. Copy Ctrl-Ins ȁİȚIJȠȣȡȖİȓ ʌĮȡȩȝȠȚĮ ȝİ IJȘȞ Cut, ȝİ IJȘ įȚĮijȠȡȐ ȩIJȚ įİȞ ĮʌȠțȩʌIJİȚ IJȠ IJȝȒȝĮ țİȚȝȑȞȠȣ Įʌȩ IJȘȞ ĮȡȤȚțȒ IJȠȣ șȑıȘ, ĮʌȜȫȢ ĮȞIJȚȖȡȐijİȚ IJȠ İʌȚȜİȖȝȑȞȠ IJȝȒȝĮ țİȚȝȑȞȠȣ ıIJȠ clipboard. DzIJıȚ ȝʌȠȡȠȪȝİ ȝİIJȐ, ĮȣIJȩ IJȠ IJȝȒȝĮ țİȚȝȑȞȠȣ ȞĮ IJȠ ʌȡȠıĮȡIJȒıȠȣȝİ ȠʌȠȣįȒʌȠIJİ, İȓIJİ ıIJȠ ȓįȚȠ ĮȡȤİȓȠ, İȓIJİ ı'ȑȞĮ ȐȜȜȠ ĮȡȤİȓȠ ıİ ȐȜȜȠ ʌĮȡȐșȣȡȠ. Paste Shift-Ins ȆȡȠıĮȡIJȐ IJȠ țİȓȝİȞȠ ʌȠȣ ȣʌȐȡȤİȚ ıIJȠ clipboard, ıIJȘȞ șȑıȘ ʌȠȣ ȕȡȓıțİIJĮȚ Ƞ įȡȠȝȑĮȢ. īȚĮ ȞĮ ȝʌȠȡİȓ ȑȞĮ IJȝȒȝĮ țİȚȝȑȞȠȣ ȞĮ ʌȡȠıĮȡIJȘșİȓ, șĮ ʌȡȑʌİȚ ʌȡȫIJĮ ȞĮ ȑȤİȚ ĮȞIJȚȖȡĮijİȓ Ȓ ĮʌȠțȠʌİȓ Įʌȩ ȑȞĮ ĮȡȤİȓȠ țİȚȝȑȞȠȣ. Ǿ Paste ȤȡȘıȚȝȠʌȠȚİȓ ʌȐȞIJĮ IJȠ IJİȜİȣIJĮȓȠ IJȝȒȝĮ țİȚȝȑȞȠȣ ʌȠȣ ȑȤİȚ IJȠʌȠșİIJȘșİȓ ıIJȠ clipboard. Copy example ȉȠ ıȪıIJȘȝĮ ȕȠȒșİȚĮȢ IJȘȢ Turbo Pascal İțIJȩȢ Įʌȩ IJȘȞ ʌĮȡȠȤȒ ʌȜȘȡȠijȠȡȚȫȞ ʌİȡȚȑȤİȚ țĮȚ ȑȞĮ ʌĮȡȐįİȚȖȝĮ țȫįȚțĮ ʌȠȣ įİȓȤȞİȚ ʌȫȢ ȝʌȠȡİȓ ȞĮ ȤȡȘıȚȝȠʌȠȚȘșİȓ ȝȚĮ įȚĮįȚțĮıȓĮ Ȓ ıȣȞȐȡIJȘıȘ. Ǿ Copy example (ĮȞIJȚȖȡĮijȒ ʌĮȡĮįİȓȖȝĮIJȠȢ) ĮȞIJȚȖȡȐijİȚ ĮȣIJȩ IJȠ ʌĮȡȐįİȚȖȝĮ ıIJȠ clipboard, ȝİ ıțȠʌȩ ȞĮ IJȠ ʌȡȠıĮȡIJȒıȠȣȝİ ıIJȠ ʌȡȩȖȡĮȝȝȐ ȝĮȢ. ǹȢ ıȘȝİȚȫıȠȣȝİ ȩIJȚ IJȠ ʌĮȡȐįİȚȖȝĮ İȓȞĮȚ ʌȡȠİʌȚȜİȖȝȑȞȠ, ȠʌȩIJİ įİ ȤȡİȚȐȗİIJĮȚ ȞĮ IJȠ İʌȚȜȑȟȠȣȝİ İȝİȓȢ ʌȡȚȞ IJȠ ĮȞIJȚȖȡȐȥȠȣȝİ. Show clipboard ȆĮȡȠȣıȚȐȗİȚ ıİ ȑȞĮ ʌĮȡȐșȣȡȠ IJĮ ʌİȡȚİȤȩȝİȞĮ IJȠȣ clipboard. DzȞĮ ȝȑȡȠȢ IJȠȣ țİȚȝȑȞȠȣ IJȠȣ ʌĮȡĮșȪȡȠȣ ĮȣIJȠȪ, İȓȞĮȚ ijȦIJȚıȝȑȞȠ. ǹȣIJȩ İȓȞĮȚ IJȠ IJȝȒȝĮ țİȚȝȑȞȠȣ ʌȠȣ ʌİȡȚȝȑȞİȚ ȞĮ ʌȡȠıĮȡIJȘșİȓ ıİ țȐʌȠȚȠ ʌĮȡȐșȣȡȠ. ȂʌȠȡȠȪȝİ, ĮȞ șȑȜȠȣȝİ, ȞĮ IJȡȠʌȠʌȠȚȒıȠȣȝİ ĮȣIJȩ IJȠ țİȓȝİȞȠ. Clear Ctrl-Del ǻȚĮȖȡȐijİȚ ȑȞĮ İʌȚȜİȖȝȑȞȠ țİȓȝİȞȠ, ĮȜȜȐ įİȞ IJȠ ĮȞIJȚȖȡȐijİȚ ıIJȠ clipboard. ǹȣIJȩ ȑȤİȚ ȦȢ ĮʌȠIJȑȜİıȝĮ, IJȠ țİȓȝİȞȠ ʌȠȣ įȚĮȖȡȐijİIJĮȚ ȞĮ ȝȘ ȝʌȠȡİȓ ȞĮ ĮȞĮțIJȘșİȓ. x

ȉȠ ȂİȞȠȪ Run

ǹijȠȪ ȖȡȐȥȠȣȝİ IJȠ ʌȡȩȖȡĮȝȝȐ ȝĮȢ, ȝʌȠȡȠȪȝİ ȞĮ IJȠ ȝİIJĮȖȜȦIJIJȓıȠȣȝİ țĮȚ ȞĮ IJȠ İțIJİȜȑıȠȣȝİ ȝİ IJȘ ȕȠȒșİȚĮ IJȠȣ ȝİȞȠȪ Run. Ǿ ȕĮıȚțȩIJİȡȘ İʌȚȜȠȖȒ IJȠȣ ȝİȞȠȪ İȓȞĮȚ Ș İʌȚȜȠȖȒ: Run Ctrl-F9 ȂİIJĮȖȜȦIJIJȓȗİȚ țĮȚ İțIJİȜİȓ IJȠ ʌȡȩȖȡĮȝȝȐ ȝĮȢ ȝİ ȝȚĮ įȚĮIJĮȖȒ. x

ȉȠ ȂİȞȠȪ Compile

Ȃİ IJȚȢ İʌȚȜȠȖȑȢ IJȠȣ ȝİȞȠȪ ĮȣIJȠȪ, ȝʌȠȡȠȪȝİ ȞĮ ȝİIJĮȖȜȦIJIJȓıȠȣȝİ ȝȑȡȠȢ Ȓ ȠȜȩțȜȘȡȠ IJȠ ʌȡȩȖȡĮȝȝȐ ȝĮȢ țĮȚ ȞĮ țĮșȠȡȓıȠȣȝİ ʌȠȣ șĮ ĮʌȠșȘțİȣIJİȓ IJȠ ȝİIJĮȖȜȦIJIJȚıȝȑȞȠ ʌȡȩȖȡĮȝȝĮ. Ǿ ȕĮıȚțȩIJİȡȘ İʌȚȜȠȖȒ IJȠȣ ȝİȞȠȪ İȓȞĮȚ Ș İʌȚȜȠȖȒ:


ȉȠ ȆİȡȚȕȐȜȜȠȞ IJȘȢ Turbo Pascal

5

Compile Alt-F9 ȂİIJĮȖȜȦIJIJȓȗİȚ IJȠȞ țȫįȚțĮ ʌȠȣ ȕȡȓıțİIJĮȚ ıIJȠ İȞİȡȖȩ ʌĮȡȐșȣȡȠ įȚȩȡșȦıȘȢ. ȂȓĮ ȐȜȜȘ İʌȚȜȠȖȒ IJȠȣ ȝİȞȠȪ Compile İȓȞĮȚ Ș Destination, ȝİ IJȘȞ İʌȚȜȠȖȒ ĮȣIJȒ ȑȤȠȣȝİ IJȘ įȣȞĮIJȩIJȘIJĮ ȞĮ ĮʌȠșȘțİȪıȠȣȝİ IJȠȞ İțIJİȜȑıȚȝȠ țȫįȚțĮ (.ǼȋǼ ĮȡȤİȓȠ) ʌȠȣ įȘȝȚȠȣȡȖİȓIJĮȚ ȝİIJȐ IJȠ IJȑȜȠȢ IJȘȢ ȝİIJȐijȡĮıȘȢ, İȓIJİ ıIJȘȞ țȪȡȚĮ ȝȞȒȝȘ (ĮȞ Destination Memory) İȓIJİ ıIJȠ įȓıțȠ (ĮȞ Destination Disk) 1.3 ȅ ȈȣȞIJȐțIJȘȢ ȀİȚȝȑȞȠȣ ȈIJȘȞ țȐIJȦ ĮȡȚıIJİȡȒ ȖȦȞȓĮ IJȘȢ ȠșȩȞȘȢ IJȠȣ ʌİȡȚȕȐȜȜȠȞIJȠȢ IJȘȢ Turbo Pascal, ȣʌȐȡȤȠȣȞ įȪȠ ĮȡȚșȝȠȓ ȠȚ ȠʌȠȓȠȚ țȐșİ ıIJȚȖȝȒ įİȓȤȞȠȣȞ IJȘ șȑıȘ IJȠȣ įȡȠȝȑĮ ȝȑıĮ ıIJȠ țİȓȝİȞȠ, (ʌ.Ȥ. 2:5 ıȘȝĮȓȞİȚ 2Ș ȖȡĮȝȝȒ țĮȚ ʌȑȝʌIJȘ ıIJȒȜȘ). ȉȠ ʌĮȡȐșȣȡȠ țİȚȝȑȞȠȣ ʌȠȣ ȕȜȑʌȠȣȝİ țȐșİ ıIJȚȖȝȒ ȝʌȡȠıIJȐ ȝĮȢ ȑȤİȚ ʌȜȐIJȠȢ 78 ıIJȘȜȫȞ. ǹȞ ȖȡȐȥȠȣȝİ ʌȑȡĮȞ IJȦȞ 78 ıIJȘȜȫȞ, IJȠ ȒįȘ ȖȡĮȝȝȑȞȠ țİȓȝİȞȠ ȝİIJĮțȚȞİȓIJĮȚ ʌȡȠȢ IJĮ ĮȡȚıIJİȡȐ țĮșȫȢ ȖȡȐijȠȣȝİ. ȀĮșȫȢ İȓȝĮıIJİ ıİ țĮIJȐıIJĮıȘ ıȪȞIJĮȟȘȢ țİȚȝȑȞȠȣ ȝʌȠȡȠȪȝİ ȞĮ ʌȐȡȠȣȝİ ȕȠȒșİȚĮ ȖȚĮ țȐʌȠȚĮ ȜȑȟȘ-țȜİȚįȓ (įİıȝİȣȝȑȞȘ ȜȑȟȘ Ȓ ʌȡȩIJȣʌȠ ĮȞĮȖȞȦȡȚıIJȚțȩ) ĮȞ IJȠʌȠșİIJȒıȠȣȝİ IJȠ įȡȠȝȑĮ ıİ ȠʌȠȚȠįȒʌȠIJİ ıȘȝİȓȠ IJȘȢ ȜȑȟȘȢ țĮȚ ʌĮIJȒıȠȣȝİ IJȠ ıȣȞįȣĮıȝȩ ʌȜȒțIJȡȦȞ Ctrl-F1. ǼʌȓıȘȢ ʌĮIJȫȞIJĮȢ IJȠ ʌȜȒțIJȡȠ F1 ʌĮȓȡȞȠȣȝİ ıȣȞĮijȒ ȕȠȒșİȚĮ (įȘȜĮįȒ ʌĮȓȡȞȠȣȝİ ȕȠȒșİȚĮ ȖȚĮ IJȠ ȝȑȡȠȢ IJȠȣ ʌİȡȚȕȐȜȜȠȞIJȠȢ IJȘȢ Turbo Pascal ıIJȠ ȠʌȠȓȠ ȕȡȚıțȩȝĮıIJİ: ȝİȞȠȪ, ıȣȞIJȐțIJȘ țİȚȝȑȞȠȣ ț.Ȝ.ʌ.). Ȃİ IJȠ ıȣȞįȣĮıȝȩ ʌȜȒțIJȡȦȞ Alt-F1 İȝijĮȞȓȗİIJĮȚ Ș IJİȜİȣIJĮȓĮ İʌȚȜİȖȝȑȞȘ ȕȠȒșİȚĮ. ǼȞIJȠȜȑȢ ȖȚĮ IJȠ ıȣȞIJȐțIJȘ ȅȚ ȕĮıȚțȑȢ İȞIJȠȜȑȢ ȖȚĮ IJȠ ıȣȞIJȐțIJȘ IJȘȢ Turbo Pascal ʌİȡȚȖȡȐijȠȞIJĮȚ Įʌȩ IJȠ ıȪıIJȘȝĮ ȤȡȘıȚȝȠʌȠȚȫȞIJĮȢ IJȠ ʌȜȒțIJȡȠ F1 (ȕȠȒșİȚĮ). ǼʌȓıȘȢ ĮȣIJȑȢ ȠȚ İȞIJȠȜȑȢ ijĮȓȞȠȞIJĮȚ țĮȚ ıIJȠȞ ȆȓȞĮțĮ 1.1. ȊʌȐȡȤȠȣȞ ȩȝȦȢ ȝİȡȚțȑȢ İȞIJȠȜȑȢ ʌȠȣ ȤȡİȚȐȗȠȞIJĮȚ țȐʌȠȚĮ İʌİȟȒȖȘıȘ. ǵIJĮȞ șȑȜȠȣȝİ ȞĮ İʌİȟİȡȖĮıIJȠȪȝİ ȑȞĮ IJȝȒȝĮ (block) IJȠȣ ʌȡȠȖȡȐȝȝĮIJȩȢ ȝĮȢ, IJȩIJİ ȖȚĮ ȞĮ ȠȡȓıȠȣȝİ ĮȣIJȩ IJȠ IJȝȒȝĮ IJȠʌȠșİIJȠȪȝİ IJȠ įȡȠȝȑĮ țȐIJȦ Įʌȩ IJȠ ʌȡȫIJȠ ȖȡȐȝȝĮ IJȠȣ IJȝȒȝĮIJȠȢ țĮȚ ʌĮIJȐȝİ IJȠ ıȣȞįȣĮıȝȩ IJȦȞ ʌȜȒțIJȡȦȞ Ctrl-K B, ıIJȘ ıȣȞȑȤİȚĮ IJȠʌȠșİIJȠȪȝİ IJȠ įȡȠȝȑĮ ıIJȘȞ ĮȝȑıȦȢ İʌȩȝİȞȘ șȑıȘ ȝİIJȐ IJȠ IJİȜİȣIJĮȓȠ ȖȡȐȝȝĮ IJȠȣ IJȝȒȝĮIJȠȢ țĮȚ ʌĮIJȐȝİ Ctrl-K K. ǹʌȩ IJȘ ıIJȚȖȝȒ ʌȠȣ ȠȡȓıȠȣȝİ ȝİ ĮȣIJȩȞ IJȠȞ IJȡȩʌȠ ȑȞĮ IJȝȒȝĮ ȝʌȠȡȠȪȝİ ȞĮ IJȠ ĮȞIJȚȖȡȐȥȠȣȝİ, ȞĮ IJȠ įȚĮȖȡȐȥȠȣȝİ, ȞĮ IJȠ ȝİIJĮijȑȡȠȣȝİ ıİ ȐȜȜȠ ıȘȝİȓȠ IJȠȣ țİȚȝȑȞȠȣ ȝĮȢ, ȞĮ IJȠ ĮʌȠșȘțİȪıȠȣȝİ ıIJȠ įȓıțȠ Ȓ ȞĮ IJȠ țȐȞȠȣȝİ ȞĮ ȝȘ ijĮȓȞİIJĮȚ ȩIJȚ İȓȞĮȚ İʌȚȜİȖȝȑȞȠ (ȠȡȚıȝȑȞȠ). īȚĮ ȞĮ țȐȞȠȣȝİ ȩȜĮ IJĮ ʌĮȡĮʌȐȞȦ ı'ȑȞĮ IJȝȒȝĮ ʌȡȑʌİȚ ĮijȠȪ IJȠ ȠȡȓıȠȣȝİ, ȞĮ ʌĮIJȒıȠȣȝİ IJȠȣȢ țĮIJȐȜȜȘȜȠȣȢ ıȣȞįȣĮıȝȠȪȢ ʌȜȒțIJȡȦȞ ʌȠȣ ijĮȓȞȠȞIJĮȚ ıIJȠȞ ȆȓȞĮțĮ 1.1. Ǽįȫ ȞĮ ʌȠȪȝİ ȩIJȚ, ȩʌȠȣ ȕȜȑʌȠȣȝİ ıȣȞįȣĮıȝȠȪȢ ʌȜȒțIJȡȦȞ IJȠȣ IJȪʌȠȣ Ctrl (Ȓ Alt Ȓ ȠIJȚįȒʌȠIJİ ȐȜȜȠ)-A B, ıȘȝĮȓȞİȚ ȩIJȚ ȑȤȠȞIJĮȢ ʌĮIJȘȝȑȞȠ IJȠ ʌȜȒțIJȡȠ Ctrl (Ȓ Alt Ȓ ȠIJȚįȒʌȠIJİ ȐȜȜȠ) ʌĮIJȐȝİ țĮȚ IJȠ ʌȜȒțIJȡȠ ǹ, ȝİIJȐ ĮijȒȞȠȣȝİ ĮȣIJȐ IJĮ ʌȜȒțIJȡĮ țĮȚ ʌĮIJȐȝİ IJȠ Ǻ. ǼȞIJȠȜȑȢ ȝİIJĮțȓȞȘıȘȢ įȡȠȝȑĮ DzȞĮȢ ȤĮȡĮțIJȒȡĮȢ ĮȡȚıIJİȡȐ DzȞĮȢ ȤĮȡĮțIJȒȡĮȢ įİȟȚȐ ȂȓĮ ȜȑȟȘ ĮȡȚıIJİȡȐ ȂȓĮ ȜȑȟȘ įİȟȚȐ ȂȓĮ ȖȡĮȝȝȒ ʌȐȞȦ ȂȓĮ ȖȡĮȝȝȒ țȐIJȦ ǹȡȤȒ ȖȡĮȝȝȒȢ ȉȑȜȠȢ ȖȡĮȝȝȒȢ ȀȪȜȚıȘ ȠșȩȞȘȢ ʌȡȠȢ IJĮ ʌȐȞȦ ȀȪȜȚıȘ ȠșȩȞȘȢ ʌȡȠȢ IJĮ țȐIJȦ ȂȓĮ ȠșȩȞȘ ʌȐȞȦ ȂȓĮ ȠșȩȞȘ țȐIJȦ ǹȡȤȒ ȠșȩȞȘȢ ȉȑȜȠȢ ȠșȩȞȘȢ

ǹș. Ǽ. ȀȠȣIJıȠȞȚțȩȜĮȢ

Ctrl-S Ctrl-D Ctrl-A Ctrl-F Ctrl-E Ctrl-X Ctrl-Q Ctrl-Q Ctrl-W Ctrl-Z Ctrl-R Ctrl-C Ctrl-Q Ctrl-Q

Ȓ Ȓ Ȓ Ȓ Ȓ Ȓ S D

Å Æ Ctrl-Å Ctrl-Æ Ç È Ȓ Home Ȓ End

Ȓ Ȓ E X

PgUp PgDn Ȓ Ctrl-Home Ȓ Ctrl-End


6

ǹȈȀǾȈǾ 1

ǹȡȤȒ țİȚȝȑȞȠȣ Ctrl-Q R Ȓ Ctrl-PgUp ȉȑȜȠȢ țİȚȝȑȞȠȣ Ctrl-Q C Ȓ Ctrl-PgDn ǼȞIJȠȜȑȢ İȚıĮȖȦȖȒȢ țĮȚ įȚĮȖȡĮijȒȢ ǼȞİȡȖȠʌȠȓȘıȘ/ĮʌİȞİȡȖȠʌȠȓȘıȘ İȚıĮȖȦȖȒȢ Ctrl-V Ȓ Ins ǼȚıĮȖȦȖȒ ȖȡĮȝȝȒȢ Ctrl-N ǻȚĮȖȡĮijȒ ȖȡĮȝȝȒȢ Ctrl-Y ǻȚĮȖȡĮijȒ ȝȑȤȡȚ IJȠ IJȑȜȠȢ ȖȡĮȝȝȒȢ Ctrl-Q Y ǻȚĮȖȡĮijȒ ĮȡȚıIJİȡȠȪ ȤĮȡĮțIJȒȡĮ IJȠȣ įȡȠȝȑĮ Ctrl-H Ȓ Backspace ǻȚĮȖȡĮijȒ ȤĮȡĮțIJȒȡĮ ıIJȘ șȑıȘ IJȠȣ įȡȠȝȑĮ Ctrl-G Ȓ Del ǻȚĮȖȡĮijȒ įİȟȚȠȪ ȤĮȡĮțIJȒȡĮ IJȠȣ įȡȠȝȑĮ Ctrl-T ǻȚĮȖȡĮijȒ IJȝȒȝĮIJȠȢ Ctrl-K Y ǼȞIJȠȜȑȢ ĮȞĮȗȒIJȘıȘȢ țĮȚ ĮȞIJȚțĮIJȐıIJĮıȘȢ ǹȞĮȗȒIJȘıȘ Ctrl-Q F ǹȞĮȗȒIJȘıȘ țĮȚ ĮȞIJȚțĮIJȐıIJĮıȘ Ctrl-Q A ǼʌĮȞȐȜȘȥȘ IJİȜİȣIJĮȓĮȢ ĮȞĮȗȒIJȘıȘȢ Ȓ ĮȞIJȚțĮIJȐıIJĮıȘȢ Ctrl-L ǻȣȞĮIJȩIJȘIJİȢ ĮȞĮȗȒIJȘıȘȢ B ǹȞĮȗȘIJȐİȚ Įʌȩ IJȘ șȑıȘ IJȠȣ įȡȠȝȑĮ țĮȚ ʌȡȠȢ IJĮ ʌȐȞȦ G ǹȞĮȗȘIJȐİȚ ı'ȠȜȩțȜȘȡȠ IJȠ țİȓȝİȞȠ, ȐıȤİIJĮ Įʌȩ IJȘ șȑıȘ IJȠȣ įȡȠȝȑĮ n ǺȡȓıțİȚ IJȘȞ n-ȠıIJȒ İȝijȐȞȚıȘ, ȝİIJȡȫȞIJĮȢ Įʌ'IJȘ ʌĮȡȠȪıĮ șȑıȘ IJȠȣ įȡȠȝȑĮ N ǹȞIJȚțĮșȚıIJȐ ȤȦȡȓȢ ȞĮ ʌİȡȚȝȑȞİȚ İʌȚȕİȕĮȓȦıȘ U ǹȖȞȠİȓ ĮȞ ȠȚ ȤĮȡĮțIJȒȡİȢ İȓȞĮȚ țİijĮȜĮȓȠȚ Ȓ ʌİȗȠȓ W ǹȞĮȗȘIJȐİȚ ȝȩȞȠ ȠȜȩțȜȘȡİȢ ȜȑȟİȚȢ L ǹȞĮȗȘIJȐİȚ IJȠʌȚțȐ (ȝȑıĮ ıIJȠ IJȝȒȝĮ ʌȠȣ ȕȡȓıțİIJĮȚ Ƞ įȡȠȝȑĮȢ) ǼȞIJȠȜȑȢ IJȝȒȝĮIJȠȢ (block) ȈȘȝİȓȦıȘ ĮȡȤȒȢ IJȝȒȝĮIJȠȢ Ctrl-K B ȈȘȝİȓȦıȘ IJȑȜȠȣȢ IJȝȒȝĮIJȠȢ Ctrl-K K ȈȘȝİȓȦıȘ ȝȚĮȢ ȜȑȟȘȢ Ctrl-K T ǹȞIJȚȖȡĮijȒ IJȝȒȝĮIJȠȢ ıIJȘ șȑıȘ IJȠȣ įȡȠȝȑĮ Ctrl-K C ȂİIJĮijȠȡȐ IJȝȒȝĮIJȠȢ ıIJȘ șȑıȘ IJȠȣ įȡȠȝȑĮ Ctrl-K V ǻȚĮȖȡĮijȒ IJȝȒȝĮIJȠȢ Ctrl-K Y ǼȚıĮȖȦȖȒ ĮȡȤİȓȠȣ ıIJȘ șȑıȘ IJȠȣ įȡȠȝȑĮ Ctrl-K R īȡȐȥȚȝȠ IJȝȒȝĮIJȠȢ ıİ ĮȡȤİȓȠ ıIJȠ įȓıțȠ Ctrl-K W ǹʌȩțȡȣȥȘ/İȝijȐȞȚıȘ IJȝȒȝĮIJȠȢ Ctrl-K H ǼțIJȪʌȦıȘ IJȝȒȝĮIJȠȢ Ctrl-K P ȈIJȠȓȤȚıȘ IJȝȒȝĮIJȠȢ Ctrl-K I ǹʌȠıIJȠȓȤȚıȘ IJȝȒȝĮIJȠȢ Ctrl-K U ǻȚȐijȠȡİȢ İȞIJȠȜȑȢ ǼȞİȡȖȠʌȠȓȘıȘ IJȠȣ ȕĮıȚțȠȪ ȝİȞȠȪ İʌȚȜȠȖȫȞ F10 DzȟȠįȠȢ Įʌȩ IJȠ ıȣȞIJȐțIJȘ Alt-X ȈȫıȚȝȠ ĮȡȤİȓȠȣ Ctrl-K S Ȓ F2 ĭȩȡIJȦıȘ ȞȑȠȣ ĮȡȤİȓȠȣ F3 ȀȜİȓıȚȝȠ İȞİȡȖȠȪ ʌĮȡĮșȪȡȠȣ Alt-F3 ȈIJȘȜȠșȑIJȘȢ Ctrl-I Ȓ Tab ǹȣIJȩȝĮIJȘ ıIJȠȓȤȚıȘ İȞIJȩȢ/İțIJȩȢ Ctrl-O I Ȓ Ctrl-Q I ǹțȪȡȦıȘ İȞIJȠȜȒȢ (Undo) Ctrl-Q L ȉȠʌȠșȑIJȘıȘ ıȘȝĮįȚȠȪ șȑıȘȢ Ctrl-K n (n=0..9) ǹȞİȪȡİıȘ ıȘȝĮįȚȠȪ șȑıȘȢ Ctrl-Q n (n=0..9) ǺȠȒșİȚĮ ȖȚĮ IJȘ ȜȑȟȘ ʌȠȣ ȕȡȓıțİIJĮȚ Ƞ įȡȠȝȑĮȢ Ctrl-F1 ǹʌȠțĮIJȐıIJĮıȘ IJİȜİȣIJĮȓȠȣ ȝȘȞȪȝĮIJȠȢ ıijȐȜȝĮIJȠȢ Ctrl-Q W ȆȓȞĮțĮȢ 1.1: ǼȞIJȠȜȑȢ ȖȚĮ IJȠ ıȣȞIJȐțIJȘ


ȉȠ ȆİȡȚȕȐȜȜȠȞ IJȘȢ Turbo Pascal

7

1.4 ǹıțȒıİȚȢ DZıțȘıȘ 1.1 ǹijȠȪ ijȠȡIJȫıİIJİ IJȘȞ Turbo Pascal, ȖȡȐȥIJİ IJȠ ʌĮȡĮțȐIJȦ ʌȡȩȖȡĮȝȝĮ: Program First; Begin Writeln('This is my First Program'); End. ȆȡȠıȑȟIJİ ȫıIJİ ȞĮ ȝȘȞ țȐȞİIJİ ȜȐșȘ țĮIJȐ IJȘȞ İȚıĮȖȦȖȒ IJȠȣ ʌȡȠȖȡȐȝȝĮIJȠȢ. ȉȠ İȜȜȘȞȚțȩ İȡȦIJȘȝĮIJȚțȩ ıIJȘȞ ʌȡȫIJȘ țĮȚ IJȡȓIJȘ ȖȡĮȝȝȒ țĮȚ Ș IJİȜİȓĮ ȝİIJȐ IJȠ End İȓȞĮȚ ĮʌĮȡĮȓIJȘIJĮ. ȈIJȘ ıȣȞȑȤİȚĮ: x

AʌȠșȘțİȪıIJİ IJȠ ʌȡȩȖȡĮȝȝĮ IJȠ ȠʌȠȓȠ ȖȡȐȥĮIJİ ȝİ IJȠ ȩȞȠȝĮ ex11 (Ș Turbo Pascal ʌȡȠıșȑIJİȚ ĮȣIJȩȝĮIJĮ IJȘȞ ʌȡȠȑțIJĮıȘ '.pas' ıIJȠ ȩȞȠȝĮ IJȠȣ ʌȡȠȖȡȐȝȝĮIJȠȢ)

x

ǹijȠȪ ȕȖİȓIJİ ʌȡȠıȦȡȚȞȐ Įʌȩ IJȠ ʌİȡȚȕȐȜȜȠȞ IJȘȢ Turbo Pascal, ȝİ IJȘȞ İʌȚȜȠȖȒ DOS shell IJȠȣ ȝİȞȠȪ File, İȜȑȖȟIJİ IJĮ ʌİȡȚİȤȩȝİȞĮ IJȠȣ țĮIJĮȜȩȖȠȣ ıIJȠȞ ȠʌȠȓȠ İȡȖȐȗİıIJİ. ȊʌȐȡȤİȚ IJȠ ĮȡȤİȓȠ ex11.pas;

x

ȆȜȘțIJȡȠȜȠȖȒıIJİ EXIT ȖĮ İʌȚıIJȡȠijȒ ıIJȠ ʌİȡȚȕȐȜȜȠȞ IJȘȢ Turbo Pascal. ȋȡȘıȚȝȠʌȠȚȒıIJİ IJȘȞ İʌȚȜȠȖȒ New IJȠȣ ȝİȞȠȪ File ȖȚĮ ȞĮ ȟİțȚȞȒıİIJİ IJȠ ȖȡȐȥȚȝȠ İȞȩȢ ȞȑȠȣ ʌȡȠȖȡȐȝȝĮIJȠȢ.

x

īȡȐȥIJİ țȐʌȠȚȠ İȜİȪșİȡȠ țİȓȝİȞȠ. ȆȡȠıʌĮșȒıIJİ ȞĮ țȐȞİIJİ įȚȠȡșȫıİȚȢ ıIJȠ țİȓȝİȞȠ IJȠ ȠʌȠȓȠ ȖȡȐȥĮIJİ. ȋȡȘıȚȝȠʌȠȚȒıIJİ İʌȓıȘȢ IJȚȢ İʌȚȜȠȖȑȢ ȖȚĮ IJȘȞ ĮȞIJȚȖȡĮijȒ, ȝİIJĮțȓȞȘıȘ țĮȚ įȚĮȖȡĮijȒ IJȝȘȝȐIJȦȞ IJȠȣ țİȚȝȑȞȠȣ.

DZıțȘıȘ 1.2 ȋȡȘıȚȝȠʌȠȚȒıIJİ IJȘȞ İʌȚȜȠȖȒ Load IJȠȣ ȝİȞȠȪ File ȖȚĮ ȞĮ ĮȞȠȓȟİIJİ IJȠ ĮȡȤİȓȠ ex11.pas IJȠ ȠʌȠȓȠ ȖȡȐȥĮIJİ ıIJȘȞ DZıțȘıȘ 1.1. ȈIJȘȞ ıȣȞȑȤİȚĮ: x

ȂİIJĮijȡȐıIJİ țĮȚ İțIJİȜȑıIJİ IJȠ ʌȡȩȖȡĮȝȝĮ.

x

ȉȡȠʌȠʌȠȚȒıIJİ IJȠ ʌȡȩȖȡĮȝȝĮ ȫıIJİ ıIJȘȞ ȠșȩȞȘ ȞĮ IJȣʌȫȞİIJĮȚ IJȠ ȩȞȠȝȐ ıĮȢ.

x

ǹijȠȪ ȕȖİȓIJİ ʌȡȠıȦȡȚȞȐ Įʌȩ IJȠ ʌİȡȚȕȐȜȜȠȞ IJȘȢ Turbo Pascal, ȝİ IJȘȞ İʌȚȜȠȖȒ DOS shell IJȠȣ ȝİȞȠȪ File, İȜȑȖȟIJİ IJĮ ʌİȡȚİȤȩȝİȞĮ IJȠȣ țĮIJĮȜȩȖȠȣ ıIJȠȞ ȠʌȠȓȠ İȡȖȐȗİıIJİ. ȊʌȐȡȤİȚ IJȠ ĮȡȤİȓȠ ex11.pas țĮȚ IJȠ ĮȡȤİȓȠ ex11.exe; ȉȚ İȓȞĮȚ IJȠ ĮȡȤİȓȠ ex11.exe; ȆȫȢ ȝʌȠȡİȓIJİ ȞĮ IJȡȑȟİIJİ țȐʌȠȚȠ ʌȡȩȖȡĮȝȝĮ Įʌȩ IJȠ ȜİȚIJȠȣȡȖȚțȩ ıȪıIJȘȝĮ DOS;

ȈȘȝİȓȦıȘ: īȚĮ ȞĮ įȘȝȚȠȣȡȖȘșİȓ IJȠ ĮȡȤİȓȠ ex11.exe șĮ ʌȡȑʌİȚ ıIJȠ ȝİȞȠȪ Compile ȞĮ İȝijĮȞȓȗİIJĮȚ Ș Destination Disk. ǼȐȞ İȝijĮȞȓȗİIJĮȚ ıIJȘ șȑıȘ IJȘȢ Ș Destination Memory, IJȩIJİ ĮʌȜȐ įȚĮȜȑȟIJİ IJȘȞ İʌȚȜȠȖȒ Destination Memory țĮȚ ʌĮIJȒıIJİ ENTER ȖȚĮ ȞĮ ĮȜȜȐȟİȚ. DZıțȘıȘ 1.3 īȡȐȥIJİ IJȠ ʌĮȡĮțȐIJȦ ʌȡȩȖȡĮȝȝĮ țĮȚ ĮʌȠșȘțİȪıIJİ IJȠ ȝİ IJȠ ȩȞȠȝĮ ex13.pas Program Second; Begin Write('T.E.I. '); Writeln('ȁĮȝȓĮȢ'); Writeln('Ȉ.ȉ.Ǽĭ.'); Write('TȝȒȝĮ '); Writeln('ȆȜȘȡȠijȠȡȚțȒȢ'); End.

ǹș. Ǽ. ȀȠȣIJıȠȞȚțȩȜĮȢ


8

ǹȈȀǾȈǾ 1

x

ǼțIJİȜȑıIJİ IJȠ ʌȡȩȖȡĮȝȝĮ țĮȚ ʌĮȡĮIJȘȡȒıIJİ IJĮ ȝȘȞȪȝĮIJĮ IJĮ ȠʌȠȓĮ İțIJȣʌȫȞȠȞIJĮȚ ıIJȘȞ ȠșȩȞȘ. ȆȠȚĮ İȓȞĮȚ țĮIJȐ IJȘȞ ȖȞȫȝȘ ıĮȢ Ș įȚĮijȠȡȐ IJȦȞ İȞIJȠȜȫȞ Write țĮȚ Writeln; (ǹȣIJȑȢ IJȚȢ İȞIJȠȜȑȢ șĮ IJȚȢ įȠȪȝİ ĮȞĮȜȣIJȚțȐ ıIJȘȞ İʌȩȝİȞȘ ǼȡȖĮıIJȘȡȚĮțȒ DZıțȘıȘ)

x

ȉȡȠʌȠʌȠȚȒıIJİ IJȠ ʌȡȩȖȡĮȝȝĮ țĮȚ ʌȡȠıʌĮșȒıIJİ ȞĮ IJȣʌȫıİIJİ įȚțȐ ıĮȢ ȝȘȞȪȝĮIJĮ țȐȞȠȞIJĮȢ ȤȡȒıȘ IJȦȞ İȞIJȠȜȫȞ Write țĮȚ Writeln. ȈǾȂǼǿȍȈǼǿȈ

_____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________


9

ǹȈȀǾȈǾ 2 ǹʌȜȐ ȆȡȠȖȡȐȝȝĮIJĮ 2.1 ǼȚıĮȖȦȖȒ ȆȡȩȖȡĮȝȝĮ İȓȞĮȚ ȝȓĮ ĮțȠȜȠȣșȓĮ İȞIJȠȜȫȞ ʌȠȣ ʌİȡȚȖȡȐijȠȣȞ įȚȐijȠȡİȢ İȞȑȡȖİȚİȢ ʌȠȣ ʌȡȑʌİȚ ȞĮ ȖȓȞȠȣȞ ıIJĮ įİįȠȝȑȞĮ ȫıIJİ ȞĮ ʌȐȡȠȣȝİ IJĮ ȗȘIJȠȪȝİȞĮ ĮʌȠIJİȜȑıȝĮIJĮ. ȅȚ ȝİIJĮȕȜȘIJȑȢ țĮȚ ȠȚ İȞIJȠȜȑȢ İȓȞĮȚ ĮʌĮȡĮȓIJȘIJĮ ıIJȠȚȤİȓĮ ȖȚĮ ȠʌȠȚĮįȒʌȠIJİ ȖȜȫııĮ ʌȡȠȖȡĮȝȝĮIJȚıȝȠȪ. ȅȚ İȞIJȠȜȑȢ İȓȞĮȚ ȠįȘȖȓİȢ ʌȡȠȢ IJȠȞ İʌİȟİȡȖĮıIJȒ IJȠȣ Ǿ/Ȋ ȠȚ ȠʌȠȓİȢ İțIJİȜȠȪȞIJĮȚ ȝİ ȝȚĮ ȠȡȚıȝȑȞȘ ıİȚȡȐ țĮȚ ȤİȚȡȓȗȠȞIJĮȚ įİįȠȝȑȞĮ. ȉĮ įİįȠȝȑȞĮ ĮȣIJȐ ĮʌȠșȘțİȪȠȞIJĮȚ ıIJȚȢ ȝİIJĮȕȜȘIJȑȢ ȠȚ ȠʌȠȓİȢ ȠȡȓȗȠȞIJĮȚ ıIJȠ ʌȡȩȖȡĮȝȝĮ. ȅȚ İȞIJȠȜȑȢ įȚĮȕȐȗȠȣȞ Įʌȩ IJȠ ʌȜȘțIJȡȠȜȩȖȚȠ, IJȠȞ įȓıțȠ Ȓ IJȚȢ įȚȐijȠȡİȢ ȐȜȜİȢ ʌİȡȚijİȡİȚĮțȑȢ ȝȠȞȐįİȢ IJȚȢ IJȚȝȑȢ IJȦȞ ȝİIJĮȕȜȘIJȫȞ, IJȚȢ İʌİȟİȡȖȐȗȠȞIJĮȚ țĮȚ IJȑȜȠȢ İțIJȣʌȫȞȠȣȞ ıIJȘȞ ȠșȩȞȘ Ȓ ıİ ȐȜȜİȢ ʌİȡȚijİȡİȚĮțȑȢ ȝȠȞȐįİȢ IJĮ ĮʌȠIJİȜȑıȝĮIJĮ. ȀȐșİ ʌȡȩȖȡĮȝȝĮ ʌȠȣ ȖȡȐijȠȣȝİ ıIJȘȞ Pascal (ȩʌȦȢ țĮȚ ıİ țȐșİ ȖȜȫııĮ ʌȡȠȖȡĮȝȝĮIJȚıȝȠȪ) ʌȡȑʌİȚ ȞĮ ȑȤİȚ ȝȓĮ ıȣȖțİțȡȚȝȑȞȘ įȠȝȒ. 2.2 ǻȠȝȒ ȆȡȠȖȡȐȝȝĮIJȠȢ ȀȐșİ ʌȡȩȖȡĮȝȝĮ IJȘȢ Pascal ĮʌȠIJİȜİȓIJĮȚ ȕĮıȚțȐ Įʌȩ IJȡȓĮ ȝȑȡȘ: IJȘȞ ǼʌȚțİijĮȜȓįĮ (Heading), IJȠ ȉȝȒȝĮ ǻȘȜȫıİȦȞ (Declaration Section) țĮȚ IJȠ ǼțIJİȜȑıȚȝȠ ȉȝȒȝĮ (Executable Section). Ǿ ȖİȞȚțȒ ȝȠȡijȒ İȞȩȢ ʌȡȠȖȡȐȝȝĮIJȠȢ Pascal ijĮȓȞİIJĮȚ ʌĮȡĮțȐIJȦ: ǵȞȠȝĮ ȆȡȠȖȡȐȝȝĮIJȠȢ; ǼʌȚțİijĮȜȓįĮ ǻȘȜȫıİȚȢ ȂȠȞȐįȦȞ; ǻȘȜȫıİȚȢ ǼIJȚțİIJȫȞ; ǻȘȜȫıİȚȢ ȈIJĮșİȡȫȞ; ȉȝȒȝĮ ǻȘȜȫıİȦȞ ǻȘȜȫıİȚȢ ȉȪʌȦȞ; ǻȘȜȫıİȚȢ ȂİIJĮȕȜȘIJȫȞ; ǻȘȜȫıİȚȢ ȊʌȠʌȡȠȖȡĮȝȝȐIJȦȞ; Begin ǼȞIJȠȜȒ1; ... ȀȪȡȚȠ ȆȡȩȖȡĮȝȝĮ ... ǼțIJİȜȑıȚȝȠ ȉȝȒȝĮ ... ǼȞIJȠȜȒn; End. H İʌȚțİijĮȜȓįĮ IJȠȣ ʌȡȠȖȡȐȝȝĮIJȠȢ ĮȡȤȓȗİȚ ȝİ IJȘ įİıȝİȣȝȑȞȘ ȜȑȟȘ Program țĮȚ ıȣȞİȤȓȗİȚ ȝİ IJȠ ȩȞȠȝĮ IJȠȣ ʌȡȠȖȡȐȝȝĮIJȠȢ. ȈIJȘȞ Turbo Pascal. Ș İʌȚțİijĮȜȓįĮ İȓȞĮȚ IJİȜİȓȦȢ ʌȡȠĮȚȡİIJȚțȒ İȞȫ ıİ ȐȜȜİȢ İțįȩıİȚȢ IJȘȢ Pascal İȓȞĮȚ ȣʌȠȤȡİȦIJȚțȒ. ȀĮȜȩ ȩȝȦȢ İȓȞĮȚ ȞĮ ȕȐȗȠȣȝİ ʌȐȞIJĮ ȠȞȩȝĮIJĮ ıIJĮ ʌȡȠȖȡȐȝȝĮIJȐ ȝĮȢ, ȑȞĮ țĮȜȠįȚĮȜİȖȝȑȞȠ ȩȞȠȝĮ ȝĮȢ șȣȝȓȗİȚ ĮȝȑıȦȢ ʌȠȚȠ İȓȞĮȚ IJȠ șȑȝĮ IJȠȣ ʌȡȠȖȡȐȝȝĮIJȠȢ. ȉȠ IJȝȒȝĮ įȘȜȫıİȦȞ ʌİȡȚȑȤİȚ ȩȜİȢ IJȚȢ įȘȜȫıİȚȢ țĮȚ IJȠȣȢ ȠȡȚıȝȠȪȢ ȖȚĮ IJĮ ĮȞĮȖȞȦȡȚıIJȚțȐ (ȠȞȩȝĮIJĮ ıIJĮșİȡȫȞ, ȝİIJĮȕȜȘIJȫȞ ț.Ȝ.ʌ.) ʌȠȣ ȤȡȘıȚȝȠʌȠȚȠȪȞIJĮȚ ıIJȠ İțIJİȜȑıȚȝȠ IJȝȒȝĮ. Ǿ įȒȜȦıȘ IJȦȞ įİįȠȝȑȞȦȞ ıȘȝĮȓȞİȚ ĮʌȜȐ ȩIJȚ țȐȞȠȣȝİ ȖȞȦıIJȩ ıIJȠ ȝİIJĮȖȜȦIJIJȚıIJȒ ʌȠȚĮ įİįȠȝȑȞĮ ʌȡȑʌİȚ ȞĮ ĮʌȠįİȤșİȓ ȩIJĮȞ șĮ İʌİȟİȡȖĮıIJİȓ IJȠ ʌȡȩȖȡĮȝȝĮ țĮșȫȢ țĮȚ IJȠȞ IJȪʌȠ IJȦȞ įİįȠȝȑȞȦȞ ĮȣIJȫȞ. ȅ ȝİIJĮȖȜȦIJIJȚıIJȒȢ ȤȡİȚȐȗİIJĮȚ ȞĮ ȖȞȦȡȓȗİȚ ȩȤȚ ȝȩȞȠ ʌȠȚĮ įİįȠȝȑȞĮ șĮ ʌĮȡȠȣıȚĮıIJȠȪȞ ĮȜȜȐ țĮȚ IJȚ IJȪʌȠȣ İȓȞĮȚ, ȖȚĮ ȞĮ țĮIJĮȞİȓȝİȚ IJȘ ȝȞȒȝȘ ĮȞȐȜȠȖĮ țĮȚ ȖȚĮ ȞĮ İțIJİȜȑıİȚ țĮIJȐȜȜȘȜĮ IJȚȢ ʌȚșĮȞȑȢ ʌȡȐȟİȚȢ ȝİIJĮȟȪ țȐʌȠȚȦȞ įİįȠȝȑȞȦȞ. ȉȠ İțIJİȜȑıȚȝȠ IJȝȒȝĮ IJȠȣ ʌȡȠȖȡȐȝȝĮIJȠȢ ĮȡȤȓȗİȚ ʌȐȞIJȠIJİ ȝİ IJȘ įİıȝİȣȝȑȞȘ ȜȑȟȘ Begin țĮȚ IJİȜİȚȫȞİȚ ȝİ IJȘ įİıȝİȣȝȑȞȘ ȜȑȟȘ End ĮțȠȜȠȣșȠȪȝİȞȘ Įʌȩ ȝȓĮ IJİȜİȓĮ '.' ȂİIJĮȟȪ Begin țĮȚ End ȖȡȐijȠȞIJĮȚ ȠȚ İȞIJȠȜȑȢ IJȠȣ ʌȡȠȖȡȐȝȝĮIJȠȢ. ȂȑıĮ ıIJȠ ʌȡȩȖȡĮȝȝĮ


10

ǹȈȀǾȈǾ 2

ȝʌȠȡȠȪȝİ ıİ ȠʌȠȚȠįȒʌȠIJİ ıȘȝİȓȠ IJȠȣ ȞĮ IJȠʌȠșİIJȒıȠȣȝİ ıȤȩȜȚĮ ĮȞȐȝİıĮ ıIJȠȣȢ ȤĮȡĮțIJȒȡİȢ '{' țĮȚ '}'. ǵȜİȢ ȠȚ įȘȜȫıİȚȢ įİȞ İȓȞĮȚ ȣʌȠȤȡİȦIJȚțȑȢ ĮȞ įİȞ İȓȞĮȚ ĮȞĮȖțĮȓİȢ, ĮȜȜȐ ıİ ʌİȡȓʌIJȦıȘ ʌȠȣ ȣʌȐȡȤȠȣȞ IJȩIJİ șĮ ʌȡȑʌİȚ ȞĮ IJȠʌȠșİIJȘșȠȪȞ ıIJȘ ıȤİIJȚțȒ șȑıȘ ȩʌȦȢ ijĮȓȞİIJĮȚ ʌĮȡĮʌȐȞȦ. ȆĮȡȐįİȚȖȝĮ İȞȩȢ ĮʌȜȠȪ ʌȡȠȖȡȐȝȝĮIJȠȢ İȓȞĮȚ IJȠ ʌĮȡĮțȐIJȦ: Program First; Var x: Integer; Begin Write('ǻȫıİ ȑȞĮȞ ĮțȑȡĮȚȠ ĮȡȚșȝȩ '); Readln(x); Writeln ('ȅ ĮȡȚșȝȩȢ ʌȠȣ ȑįȦıİȢ İȓȞĮȚ Ƞ ', x); End. ȈIJȠ ʌȡȩȖȡĮȝȝĮ ĮȣIJȩ įȘȜȫȞİIJĮȚ ȦȢ First IJȠ ȩȞȠȝĮ IJȠȣ ʌȡȠȖȡȐȝȝĮIJȠȢ, ıIJȘȞ ıȣȞȑȤİȚĮ įȘȜȫȞİIJĮȚ ȝȚĮ ĮțȑȡĮȚĮ ȝİIJĮȕȜȘIJȒ ȝİ IJȠ ȩȞȠȝĮ X țĮȚ ıIJȘȞ ıȣȞȑȤİȚĮ ĮțȠȜȠȣșİȓ IJȠ IJȝȒȝĮ İȞIJȠȜȫȞ IJȠȣ ʌȡȠȖȡȐȝȝĮIJȠȢ IJȠ ȠʌȠȓȠ ȗȘIJȐ Įʌȩ IJȠȞ ȤȡȒıIJȘ ȞĮ İȚıȐȖİȚ ȑȞĮȞ ĮțȑȡĮȚȠ ĮȡȚșȝȩ țĮȚ IJȠȞ İțIJȣʌȫȞİȚ ıIJȘȞ ȠșȩȞȘ. ȆĮȡĮIJȘȡȒıİȚȢ x

ȉȠ ȩȞȠȝĮ İȞȩȢ ʌȡȠȖȡȐȝȝĮIJȠȢ ʌȡȑʌİȚ ȞĮ İȓȞĮȚ ȠʌȠȚȠıįȒʌȠIJİ ıȣȞįȣĮıȝȩȢ ȜĮIJȚȞȚțȫȞ ȤĮȡĮțIJȒȡȦȞ Ȓ ĮȡȚșȝȘIJȚțȫȞ ȥȘijȓȦȞ, ȝİ IJȘȞ ʌȡȠȨʌȩșİıȘ ȩIJȚ ĮȡȤȓȗİȚ Įʌȩ ȜĮIJȚȞȚțȩ ȤĮȡĮțIJȒȡĮ Ȓ IJȠȞ ȤĮȡĮțIJȒȡĮ '_' țĮȚ įİȞ İȓȞĮȚ țȐʌȠȚĮ įİıȝİȣȝȑȞȘ ȜȑȟȘ IJȘȢ Pascal.

x

ȅȚ įȚȐijȠȡİȢ įȘȜȫıİȚȢ Ȓ İȞIJȠȜȑȢ ʌȡȑʌİȚ ȞĮ IJİȜİȚȫȞȠȣȞ ȝİ IJȠ İȜȜȘȞȚțȩ İȡȦIJȘȝĮIJȚțȩ.

x

ȅȚ ȝİIJĮȕȜȘIJȑȢ ʌȡȑʌİȚ ȞĮ įȘȜȫȞȠȞIJĮȚ ĮʌȠțȜİȚıIJȚțȐ ıIJȠ IJȝȒȝĮ Var IJȠȣ ʌȡȠȖȡȐȝȝĮIJȠȢ țĮȚ ĮȞIJȓıIJȠȚȤĮ ȠȚ İȞIJȠȜȑȢ IJȠȣ ʌȡȠȖȡȐȝȝĮIJȠȢ ıIJȠ IJȝȒȝĮ İȞIJȠȜȫȞ IJȠ ȠʌȠȓȠ ĮȡȤȓȗİȚ ȝİ IJȘȞ įİıȝİȣȝȑȞȘ ȜȑȟȘ Begin țĮȚ IJİȜİȚȫȞİȚ ȝİ IJȘȞ įİıȝİȣȝȑȞȘ ȜȑȟȘ End.

x

ȈIJȠ IJȑȜȠȢ IJȠȣ ʌȡȠȖȡȐȝȝĮIJȠȢ ȝİIJȐ IJȘȞ įİıȝİȣȝȑȞȘ ȜȑȟȘ End ʌȡȑʌİȚ ȞĮ ĮțȠȜȠȣșİȓ ȣʌȠȤȡİȦIJȚțȐ IJİȜİȓĮ.

2.3 ȂİIJĮȕȜȘIJȑȢ īȚĮ IJȘȞ İʌȓȜȣıȘ İȞȩȢ ʌȡȠȕȜȒȝĮIJȠȢ ıİ Ǿ/Ȋ, șĮ ʌȡȑʌİȚ ʌȡȫIJĮ ȞĮ ʌĮȡĮıIJĮșȠȪȞ IJĮ įİįȠȝȑȞĮ IJȠȣ ʌȡȠȕȜȒȝĮIJȠȢ ȝİ ȝİIJĮȕȜȘIJȑȢ (variables). Ǿ ȝİIJĮȕȜȘIJȒ İȓȞĮȚ ĮʌȜȫȢ ȝȚĮ ʌİȡȚȠȤȒ IJȘȢ ȝȞȒȝȘȢ IJĮ ʌİȡȚİȤȩȝİȞĮ IJȘȢ ȠʌȠȓĮȢ įȪȞĮȞIJĮȚ ȞĮ ĮȜȜȐȗȠȣȞ țĮIJȐ IJȘ įȚȐȡțİȚĮ İțIJȑȜİıȘȢ IJȠȣ ʌȡȠȖȡȐȝȝĮIJȠȢ. ȈIJȘȞ ʌİȡȚȠȤȒ ĮȣIJȒ IJȘȢ ȝȞȒȝȘȢ ĮʌȠįȓįİIJĮȚ ȑȞĮ ȩȞȠȝĮ ʌȠȣ ȑȤİȚ įȘȝȚȠȣȡȖȒıİȚ Ƞ ȤȡȒıIJȘȢ. ǵȜİȢ ȠȚ ȝİIJĮȕȜȘIJȑȢ ʌȠȣ ȣʌİȚıȑȡȤȠȞIJĮȚ ıIJȠ ʌȡȩȖȡĮȝȝĮ ʌȡȑʌİȚ ȞĮ įȘȜȦșȠȪȞ ȩıȠȞ ĮijȠȡȐ IJȠȞ IJȪʌȠ IJȦȞ IJȚȝȫȞ ʌȠȣ ȜĮȝȕȐȞȠȣȞ, ȖȚĮ ȞĮ ȟȑȡİȚ Ƞ ȝİIJĮȖȜȦIJIJȚıIJȒȢ ʌȩıȠ ȤȫȡȠ ȝȞȒȝȘȢ șĮ įİıȝİȪıİȚ ȖȚĮ IJȘȞ țĮșİȝȓĮ Įʌ'ĮȣIJȑȢ. Ǿ İȡȖĮıȓĮ ĮȣIJȒ ȖȓȞİIJĮȚ ıIJȠ IJȝȒȝĮ įȘȜȫıİȦȞ ȝİ IJȘȞ İȞIJȠȜȒ įȒȜȦıȘȢ ȝİIJĮȕȜȘIJȫȞ (variable declaration) Ș ȠʌȠȓĮ ȑȤİȚ IJȘ ȝȠȡijȒ: Var ȜȓıIJĮ ȝİIJĮȕȜȘIJȫȞ1 : IJȪʌȠȢ1; ȜȓıIJĮ ȝİIJĮȕȜȘIJȫȞ2 : IJȪʌȠȢ2; .. .. .. .. ȜȓıIJĮ ȝİIJĮȕȜȘIJȫȞn : IJȪʌȠȢn;


ǹʌȜȐ ȆȡȠȖȡȐȝȝĮIJĮ

11

ȩʌȠȣ Var İȓȞĮȚ Ș įİıȝİȣȝȑȞȘ ȜȑȟȘ ʌȠȣ ȤȡȘıȚȝȠʌȠȚİȓIJĮȚ ȖȚĮ IJȘ įȒȜȦıȘ ȝİIJĮȕȜȘIJȫȞ, ȜȓıIJĮ ȝİIJĮȕȜȘIJȫȞ İȓȞĮȚ IJĮ ȠȞȩȝĮIJĮ IJȦȞ ȝİIJĮȕȜȘIJȫȞ ȤȦȡȚıȝȑȞĮ ȝİ țȩȝȝĮIJĮ ',' țĮȚ IJȪʌȠȢ İȓȞĮȚ Ƞ IJȪʌȠȢ IJȦȞ IJȚȝȫȞ ʌȠȣ ȠȡȓȗİIJĮȚ ȝİIJȐ IJȘȞ ȐȞȦ țĮȚ țȐIJȦ IJİȜİȓĮ ':'. Ǿ Pascal ʌĮȡȑȤİȚ IJȠȣȢ ʌĮȡĮțȐIJȦ ȕĮıȚțȠȪȢ IJȪʌȠȣȢ IJȚȝȫȞ: ȉȪʌȠȢ

ȆİȡȚȖȡĮijȒ

Integer

ǹțȑȡĮȚȠȢ

ȉȚȝȑȢ

ȂȑȖİșȠȢ

Įʌȩ -32768 ȝȑȤȡȚ 32767 -39

ȝȑȤȡȚ 1.710

2 bytes 38

Real

ȆȡĮȖȝĮIJȚțȩȢ

Įʌȩ 2.910

6 bytes

Char

ȋĮȡĮțIJȒȡĮȢ

ʌȓȞĮțĮȢ ȤĮȡĮțIJȒȡȦȞ ASCII

1 byte

Boolean

ȁȠȖȚțȩȢ

True Ȓ False

1 byte

Ǿ Turbo Pascal ʌȡȠıijȑȡİȚ İʌȚʌȜȑȠȞ IJȠȣȢ ʌĮȡĮțȐIJȦ IJȪʌȠȣȢ (ȠȚ IJȪʌȠȚ ĮȣIJȠȓ įİȞ İȓȞĮȚ įȚĮșȑıȚȝȠȚ ıİ ȩȜİȢ IJȚȢ İțįȩıİȚȢ IJȘȢ Pascal): ȉȪʌȠȢ

ȆİȡȚȖȡĮijȒ

ȉȚȝȑȢ

ȂȑȖİșȠȢ

Byte

ĬİIJȚțȩȢ ĮțȑȡĮȚȠȢ

Įʌȩ 0 ȝȑȤȡȚ 255

1 byte

Shortint

ȂȚțȡȩȢ ĮțȑȡĮȚȠȢ

Įʌȩ -128 ȝȑȤȡȚ 127

1 byte

Word

ĬİIJȚțȩȢ ĮțȑȡĮȚȠȢ

Įʌȩ 0 ȝȑȤȡȚ 65535

2 bytes

LongInt

ȂİȖȐȜȠȢ ĮțȑȡĮȚȠȢ

Įʌȩ -2147483648 ȝȑȤȡȚ 2147483647 -45

4 bytes

Single

ȆȡĮȖȝĮIJȚțȩȢ ĮȡȚșȝȩȢ

Įʌȩ 1.510

Double

ȆȡĮȖȝĮIJȚțȩȢ ĮȡȚșȝȩȢ

Įʌȩ 5.010-324 ȝȑȤȡȚ 1.710308

8 bytes

Extended

ȆȡĮȖȝĮIJȚțȩȢ ĮȡȚșȝȩȢ

Įʌȩ 3.410-4932 ȝȑȤȡȚ 1.1104932

10 bytes

Comp

ȆȡĮȖȝĮIJȚțȩȢ ĮȡȚșȝȩȢ

ȝȑȤȡȚ 3.410

38

18

Įʌȩ -9.210 ȝȑȤȡȚ 9.210

18

4 bytes

8 bytes

īȚĮ IJȠȞ ȠȡȚıȝȩ ĮȜijĮȡȚșȝȘIJȚțȫȞ ȝİIJĮȕȜȘIJȫȞ (ʌ.Ȥ. ȠȞȠȝĮIJİʌȫȞȣȝȠ, įȚİȪșȣȞıȘ ț.Ȝ.ʌ.) ȤȡȘıȚȝȠʌȠȚİȓIJĮȚ Ș įȒȜȦıȘ: String [ȝȒțȠȢ] ȩʌȠȣ ȝȒțȠȢ <= 255 țĮȚ ʌĮȡȚıIJȐ IJȠ ȝȑȖȚıIJȠ ʌȜȒșȠȢ IJȦȞ ȤĮȡĮțIJȒȡȦȞ ʌȠȣ ȝʌȠȡİȓ ȞĮ įİȤșİȓ Ș ĮȜijĮȡȚșȝȘIJȚțȒ ȝİIJĮȕȜȘIJȒ. ȆĮȡĮįİȓȖȝĮIJĮ įȘȜȫıİȦȞ ȝİIJĮȕȜȘIJȫȞ İȓȞĮȚ IJĮ ʌĮȡĮțȐIJȦ: Var i,j : Integer; x,y,z : Real; c : Char; st : String[80]; ȆĮȡĮIJȘȡȒıİȚȢ x

ȀĮIJȐ IJȘȞ įȒȜȦıȘ ȝİIJĮȕȜȘIJȫȞ ȝʌȠȡȠȪȝİ ıIJȘȞ ȓįȚĮ ȖȡĮȝȝȒ ȞĮ ʌĮȡĮșȑıȠȣȝİ, ȤȦȡȚıȝȑȞİȢ ȝİ țȩȝȝĮIJĮ, ʌİȡȚııȩIJİȡİȢ Įʌȩ ȝȓĮ ȝİIJĮȕȜȘIJȑȢ IJȠȣ ȚįȓȠȣ IJȪʌȠȣ.

x

ȅȚ ȝİIJĮȕȜȘIJȑȢ ȠȚ ȠʌȠȓİȢ ȤȡȘıȚȝȠʌȠȚȠȪȞIJĮȚ Įʌȩ IJȠ ʌȡȩȖȡĮȝȝĮ șĮ ʌȡȑʌİȚ ȣʌȠȤȡİȦIJȚțȐ ȞĮ įȘȜȫȞȠȞIJĮȚ țĮȚ ȞĮ IJȠȣȢ ĮʌȠįȓįȠȞIJĮȚ IJȚȝȑȢ IJȠȣ ȚįȓȠȣ IJȪʌȠȣ. īȚĮ ʌĮȡȐįİȚȖȝĮ įİȞ ȝʌȠȡȠȪȝİ ȞĮ įȫıȠȣȝİ ıİ ȝİIJĮȕȜȘIJȒ IJȪʌȠȣ Integer IJȚȝȒ ȝİ įİțĮįȚțȐ ȥȘijȓĮ Ȓ IJȚȝȒ ȝİȖĮȜȪIJİȡȘ IJȠȣ 32767.

ǹș. Ǽ. ȀȠȣIJıȠȞȚțȩȜĮȢ


12

x

ǹȈȀǾȈǾ 2

ȉĮ ȠȞȩȝĮIJĮ IJȦȞ ȝİIJĮȕȜȘIJȫȞ įİȞ ȝʌȠȡȠȪȞ ȞĮ İȓȞĮȚ įİıȝİȣȝȑȞİȢ ȜȑȟİȚȢ IJȘȢ Pascal, ĮʌȠIJİȜȠȪȞIJĮȚ Įʌȩ ȜĮIJȚȞȚțȠȪȢ ȤĮȡĮțIJȒȡİȢ Ȓ ĮȡȚșȝȠȪȢ (Ƞ ʌȡȫIJȠȢ ȤĮȡĮțIJȒȡĮȢ ʌȡȑʌİȚ ȞĮ İȓȞĮȚ ȖȡȐȝȝĮ Ȓ '_') țĮȚ įİȞ ʌĮȓȗİȚ ȡȩȜȠ İȐȞ ȠȚ ȤĮȡĮțIJȒȡİȢ İȓȞĮȚ ʌİȗȠȓ Ȓ țİijĮȜĮȓȠȚ. īȚĮ ʌĮȡȐįİȚȖȝĮ IJȠ ȠȞȩȝĮIJĮ Num, num țĮȚ NUM İȓȞĮȚ IJĮ ȓįȚĮ.

2.4 ȀĮIJĮȤȫȡȘıȘ ȉȚȝȒȢ ıİ ȂİIJĮȕȜȘIJȒ ȅȚ ȝİIJĮȕȜȘIJȑȢ ĮȡȤȚțȐ ȑȤȠȣȞ IJȣȤĮȓİȢ IJȚȝȑȢ. DzIJıȚ ʌȡȚȞ IJȘȞ ȤȡȒıȘ IJȠȣȢ șĮ ʌȡȑʌİȚ ȞĮ IJȠȣȢ ĮʌȠįȓįȠȞIJĮȚ IJȚȝȑȢ İȓIJİ ȝİ țȐʌȠȚĮ İȞIJȠȜȒ İȚıȩįȠȣ İȓIJİ ȝİ țȐʌȠȚĮ İȞIJȠȜȒ țĮIJĮȤȫȡȘıȘȢ (Ȓ İțȤȫȡȘıȘȢ Ȓ ĮȞȐșİıȘȢ IJȚȝȒȢ) ıIJȠ IJȝȒȝĮ İȞIJȠȜȫȞ IJȠȣ ʌȡȠȖȡȐȝȝĮIJȠȢ. Ǿ țĮIJĮȤȫȡȘıȘ IJȚȝȒȢ ıİ ȝİIJĮȕȜȘIJȒ ȖȓȞİIJĮȚ ȝİ IJȘ ȤȡȒıȘ IJȠȣ IJİȜİıIJȒ țĮIJĮȤȫȡȘıȘȢ := . ȆĮȡȐįİȚȖȝĮ: Program Example; Var i,j: Integer x : Real; st : String[20]; c : Char; fl : Boolean; Begin i := 1; j := 2; x := 3.14; st := 'ȉǼǿ ȁǹȂǿǹȈ'; c := 'F'; fl := True; End. 2.5 ǼȞIJȠȜȑȢ ǼıȩįȠȣ - ǼȟȩįȠȣ ȅȚ ȕĮıȚțȑȢ İȞIJȠȜȑȢ ȖȚĮ IJȘȞ ȑȟȠįȠ įİįȠȝȑȞȦȞ ıIJȘȞ ȠșȩȞȘ İȓȞĮȚ ȠȚ İȞIJȠȜȑȢ Write țĮȚ Writeln. ȅȚ ȕĮıȚțȑȢ İȞIJȠȜȑȢ ȖȚĮ IJȘȞ İȓıȠįȠ įİįȠȝȑȞȦȞ Įʌȩ IJȠ ʌȜȘțIJȡȠȜȩȖȚȠ İȓȞĮȚ ȠȚ İȞIJȠȜȑȢ Read țĮȚ Readln. ȅȚ İȞIJȠȜȑȢ Write țĮȚ Writeln Ȃİ IJȘȞ ȤȡȒıȘ IJȦȞ İȞIJȠȜȫȞ ĮȣIJȫȞ ȖȓȞİIJĮȚ İțIJȪʌȦıȘ įİįȠȝȑȞȦȞ ıIJȘȞ ȠșȩȞȘ IJȠȣ Ǿ/Ȋ. Ǿ ıȪȞIJĮȟȘ IJȠȣȢ İȓȞĮȚ Ș ʌĮȡĮțȐIJȦ: Write(ȠȡȓıȝĮIJĮ); țĮȚ Writeln(ȠȡȓıȝĮIJĮ); ȩʌȠȣ IJĮ ȠȡȓıȝĮIJĮ ȝʌȠȡİȓ ȞĮ İȓȞĮȚ ȝȓĮ Ȓ ʌİȡȚııȩIJİȡİȢ ȝİIJĮȕȜȘIJȑȢ Ȓ ıIJĮșİȡȐ ĮȜijĮȡȚșȝȘIJȚțȐ Ȓ ıIJĮșİȡȑȢ IJȚȝȑȢ, ȤȦȡȚȗȩȝİȞĮ ȝİIJĮȟȪ IJȠȣȢ ȝİ țȩȝȝĮ. ȆĮȡĮįİȓȖȝĮIJĮ: ǼțIJȪʌȦıȘ ıIJĮșİȡȠȪ ĮȜijĮȡȚșȝȘIJȚțȠȪ: Writeln('ȀĮȜȘȝȑȡĮ'); (IJȣʌȫȞİȚ IJȠ ȝȒȞȣȝĮ ȀĮȜȘȝȑȡĮ) ǼțIJȪʌȦıȘ ıIJĮșİȡȠȪ ĮȡȚșȝȠȪ: Writeln(3); (IJȣʌȫȞİȚ IJȘȞ IJȚȝȒ 3)


ǹʌȜȐ ȆȡȠȖȡȐȝȝĮIJĮ

13

ǼțIJȪʌȦıȘ ȝİIJĮȕȜȘIJȫȞ: Writeln(x); (IJȣʌȫȞİȚ IJȘȞ IJȚȝȒ IJȘȢ ȝİIJĮȕȜȘIJȒȢ x) ȈȣȞįȣĮıȝȑȞȘ İțIJȪʌȦıȘ ĮȜijĮȡȚșȝȘIJȚțȠȪ țĮȚ ȝİIJĮȕȜȘIJȒȢ Writeln('ȉȠ ĮʌȠIJȑȜİıȝĮ İȓȞĮȚ ', x); ȅȚ İȞIJȠȜȑȢ Write țĮȚ Writeln įȚĮijȑȡȠȣȞ ıIJȠȞ IJȡȩʌȠ ȝİ IJȠȞ ȠʌȠȓȠ İțIJȣʌȫȞȠȣȞ ıIJȘȞ ȠșȩȞȘ. Ǿ İȞIJȠȜȒ Write İțIJȣʌȫȞİȚ IJĮ įİįȠȝȑȞĮ ıIJȘȞ ȠșȩȞȘ țĮȚ ıIJȘȞ ıȣȞȑȤİȚĮ Ƞ įȡȠȝȑĮȢ ʌĮȡĮȝȑȞİȚ ıIJȘȞ ȓįȚĮ ȖȡĮȝȝȒ. Ǿ İʌȩȝİȞȘ İțIJȪʌȦıȘ ıIJȘȞ ȠșȩȞȘ șĮ ȖȓȞİȚ ıIJȘȞ ȓįȚĮ ȖȡĮȝȝȒ ıȣȞİȤȓȗȠȞIJĮȢ Įʌȩ IJȠ ıȘȝİȓȠ ıIJȠ ȠʌȠȓȠ ıIJĮȝȐIJȘıİ Ș ʌȡȠȘȖȠȪȝİȞȘ İțIJȪʌȦıȘ. Ǿ İȞIJȠȜȒ Writeln İțIJȣʌȫȞİȚ ıIJȘȞ ȠșȩȞȘ IJĮ įİįȠȝȑȞĮ țĮȚ ıIJȘȞ ıȣȞȑȤİȚĮ ȠįȘȖİȓ IJȠȞ įȡȠȝȑĮ ıIJȘȞ ĮȡȤȒ IJȘȢ İʌȩȝİȞȘȢ ȖȡĮȝȝȒȢ. Ǿ İʌȩȝİȞȘ İțIJȪʌȦıȘ șĮ ȟİțȚȞȒıİȚ Įʌȩ IJȘȞ ĮȡȤȒ IJȘȢ İʌȩȝİȞȘȢ ȖȡĮȝȝȒȢ. ȅȚ ʌȡĮȖȝĮIJȚțȠȓ ĮȡȚșȝȠȓ İțIJȣʌȫȞȠȞIJĮȚ ıIJȘ ȝȠȡijȒ țȚȞȘIJȒȢ ȣʌȠįȚĮıIJȠȜȒȢ (įȘȜĮįȒ ĮȞ Ș ȝİIJĮȕȜȘIJȒ x ȑȤİȚ ʌ.Ȥ. IJȘȞ IJȚȝȒ 123.4 , IJȩIJİ Ș İȞIJȠȜȒ Write(x) șĮ IJȣʌȫıİȚ 1.234000E02, ȩʌȠȣ E02 ıȘȝĮȓȞİȚ 102). ȂʌȠȡȠȪȝİ ȩȝȦȢ ȞĮ ȝȠȡijȠʌȠȚȒıȠȣȝİ IJȘȞ İțIJȪʌȦıȘ ȝȚĮȢ ʌȡĮȖȝĮIJȚțȒȢ ȝİIJĮȕȜȘIJȒȢ įȓȞȠȞIJĮȢ įȪȠ ĮȡȚșȝȠȪȢ ȝİIJȐ IJȠ ȩȞȠȝȐ IJȘȢ, ʌȠȣ ȤȦȡȓȗȠȞIJĮȚ Įʌȩ IJȘ ȝİIJĮȕȜȘIJȒ țĮȚ ȝİIJĮȟȪ IJȠȣȢ ȝİ ȐȞȦ-țȐIJȦ IJİȜİȓĮ ':'. ȅ ʌȡȫIJȠȢ ĮȡȚșȝȩȢ (ȑıIJȦ w) ĮȞIJȚʌȡȠıȦʌİȪİȚ IJȚȢ ıȣȞȠȜȚțȑȢ șȑıİȚȢ ȤĮȡĮțIJȒȡȦȞ ʌȠȣ șĮ țĮIJĮȜȐȕİȚ Ș ȑȟȠįȠȢ, İȞȫ Ƞ įİȪIJİȡȠȢ (ȑıIJȦ d) ȠȡȓȗİȚ ʌȩıĮ șĮ İȓȞĮȚ IJĮ įİțĮįȚțȐ ȥȘijȓĮ. DzIJıȚ ȝʌȠȡȠȪȝİ ȝȑıĮ ıIJȚȢ ʌĮȡİȞșȑıİȚȢ ĮȞIJȓ IJȘȢ ȝİIJĮȕȜȘIJȒȢ ȞĮ ȖȡȐȥȠȣȝİ: ȝİIJĮȕȜȘIJȒ : w : d ȈIJȘȞ ʌİȡȓʌIJȦıȘ ʌȠȣ IJȠ ʌȜȒșȠȢ IJȦȞ ĮțİȡĮȓȦȞ ȥȘijȓȦȞ ȝĮȗȓ ȝİ IJȘȞ IJİȜİȓĮ țĮȚ IJĮ įİțĮįȚțȐ ȥȘijȓĮ, İȓȞĮȚ ȝȚțȡȩIJİȡȠ Įʌȩ w IJȩIJİ țĮIJȐ IJȘȞ İțIJȪʌȦıȘ IJȠȣ ĮȡȚșȝȠȪ ʌȡȠȘȖȠȪȞIJĮȚ IJȩıĮ țİȞȐ įȚĮıIJȒȝĮIJĮ ȫıIJİ IJİȜȚțȐ IJȠ ʌȜȒșȠȢ IJȦȞ țİȞȫȞ țĮȚ IJȠ ʌȜȒșȠȢ IJȦȞ ȥȘijȓȦȞ țĮȚ IJȘȢ IJİȜİȓĮȢ, ȞĮ İȓȞĮȚ ȓıȠ ȝİ w. ȈIJȘȞ ʌİȡȓʌIJȦıȘ ʌȠȣ IJȠ w İȓȞĮȚ ȝȚțȡȩIJİȡȠ Įʌȩ IJȠȞ ĮȡȚșȝȩ IJȦȞ șȑıİȦȞ ʌȠȣ ȤȡİȚȐȗȠȞIJĮȚ ȖȚĮ ȞĮ IJȣʌȦșİȓ Ƞ ĮȡȚșȝȩȢ, IJȩIJİ ĮȖȞȠİȓIJĮȚ țĮȚ țĮIJĮȜĮȝȕȐȞȠȞIJĮȚ ȠȚ ĮʌĮȚIJȠȪȝİȞİȢ șȑıİȚȢ. Ȃİ IJȠȞ ȓįȚȠȞ ĮțȡȚȕȫȢ IJȡȩʌȠ ȝȠȡijȠʌȠȚİȓIJĮȚ țĮȚ Ș İțIJȪʌȦıȘ IJȦȞ ĮțİȡĮȓȦȞ ĮȡȚșȝȫȞ țĮȚ IJȦȞ ĮȜijĮȡȚșȝȘIJȚțȫȞ, ȝȩȞȠ ʌȠȣ İįȫ įİ ȤȡȘıȚȝȠʌȠȚȠȪȝİ IJȠȞ d. ȆĮȡȐįİȚȖȝĮ: DzıIJȦ ȩIJȚ ȝȚĮ ȝİIJĮȕȜȘIJȒ ȋ IJȪʌȠȣ Real ȑȤİȚ IJȚȝȒ: ȋ:=1.2345678900Ǽ+03 țĮȚ ȝȚĮ ȝİIJĮȕȜȘIJȒ Ȋ IJȪʌȠȣ Integer ȑȤİȚ IJȚȝȒ: Ȋ:=4321 ȉȩIJİ Ș İȞIJȠȜȒ: ĬĮ IJȣʌȫıİȚ: Write(X) 1.2345678900Ǽ+03 Write(X:1:1) 1234.6 Write(X:7:2) 1234.57 Write(X:10:3) __1234.568 Write(X:12:6) _1234.567890 Write(Y) 4321 Write(Y:1) 4321 Write(Y:7) ___4321 Write(Y:6) __4321 Write(X:7:2,Y:6) 1234.57__4321 ȩʌȠȣ ȝİ '_' ıȣȝȕȠȜȓȗȠȣȝİ IJȠ ȤĮȡĮțIJȒȡĮ țİȞȩ (space).

ǹș. Ǽ. ȀȠȣIJıȠȞȚțȩȜĮȢ


14

ǹȈȀǾȈǾ 2

ȅȚ İȞIJȠȜȑȢ Read țĮȚ Readln Ȃİ IJȚȢ İȞIJȠȜȑȢ Read țĮȚ Readln ȝʌȠȡȠȪȝİ ȞĮ įȚĮȕȐıȠȣȝİ țĮȚ ȞĮ įȫıȠȣȝİ IJȚȝȑȢ ıİ ȝİIJĮȕȜȘIJȑȢ, Įʌȩ IJȠ ʌȜȘțIJȡȠȜȩȖȚȠ. Ǿ ıȣȞȘșȚıȝȑȞȘ ʌȡĮțIJȚțȒ İȓȞĮȚ ȞĮ IJȣʌȫıȠȣȝİ ȑȞĮ ȝȒȞȣȝĮ ʌȡȠȘȖȠȣȝȑȞȦȢ ıIJȘȞ ȠșȩȞȘ ȖȚĮ ȞĮ İȞȘȝİȡȫıȠȣȝİ IJȠȞ ȤȡȒıIJȘ IJȠȣ ʌȡȠȖȡȐȝȝĮIJȠȢ. Ǿ ıȪȞIJĮȟȘ IJȠȣȢ İȓȞĮȚ Ș ʌĮȡĮțȐIJȦ: Read(ȠȡȓıȝĮIJĮ); țĮȚ Readln(ȠȡȓıȝĮIJĮ); ȩʌȠȣ IJĮ ȠȡȓıȝĮIJĮ ȝʌȠȡİȓ ȞĮ İȓȞĮȚ ȝȓĮ Ȓ ʌİȡȚııȩIJİȡİȢ ȝİIJĮȕȜȘIJȑȢ, ȤȦȡȚȗȩȝİȞİȢ ȝİIJĮȟȪ IJȠȣȢ ȝİ țȩȝȝĮ. ǵIJĮȞ Ƞ ȤȡȒıIJȘȢ ȑȤİȚ ȞĮ İȚıȐȖİȚ įȪȠ Ȓ ʌİȡȚııȩIJİȡİȢ ȝİIJĮȕȜȘIJȑȢ, ʌȡȑʌİȚ ȞĮ IJȚȢ įȚĮȤȦȡȓıİȚ ȝİIJĮȟȪ IJȠȣȢ ȝİ ȑȞĮ Ȓ ʌİȡȚııȩIJİȡĮ țİȞȐ țĮȚ ıIJȠ IJȑȜȠȢ IJȘȢ İȚıĮȖȦȖȒȢ ȞĮ ʌȜȘțIJȡȠȜȠȖȒıİȚ Enter. Ǿ İȞIJȠȜȒ Read ȝİIJȐ IJȘȞ İțIJȑȜİıȘ IJȘȢ įİȞ ĮȜȜȐȗİȚ IJȘȞ IJȡȑȤȠȣıĮ ȖȡĮȝȝȒ IJȘȢ ȠșȩȞȘȢ ıİ ĮȞIJȓșİıȘ ȝİ IJȘȞ İȞIJȠȜȒ Readln Ș ȠʌȠȓĮ ȝİIJȐ IJȘȞ İțIJȑȜİıȘ IJȘȢ ȝİIJĮijȑȡİȚ IJȠȞ įȡȠȝȑĮ ıIJȘȞ ĮȡȤȒ IJȘȢ İʌȩȝİȞȘȢ ȖȡĮȝȝȒȢ IJȘȢ ȠșȩȞȘȢ. ȆĮȡȐįİȚȖȝĮ: Program Example; Var x: Real; y: Integer; Begin Write('ǻȫıİ ȑȞĮȞ ʌȡĮȖȝĮIJȚțȩ țĮȚ ȑȞĮȞ ĮțȑȡĮȚȠ ĮȡȚșȝȩ '); Readln(x,y); Writeln('ȉȠ x İȓȞĮȚ: ', x, ' țĮȚ IJȠ y İȓȞĮȚ: ', y); End.

2.6 ǹıțȒıİȚȢ DZıțȘıȘ 2.1 x

īȡȐȥIJİ ʌȡȩȖȡĮȝȝĮ, ex21.pas, ıIJȠ ȠʌȠȓȠ ȞĮ ȠȡȓıİIJİ ȝȓĮ ʌȡĮȖȝĮIJȚțȒ ȝİIJĮȕȜȘIJȒ ȝİ ȩȞȠȝĮ x țĮȚ ȝȓĮ ĮȜijĮȡȚșȝȘIJȚțȒ ȝİIJĮȕȜȘIJȒ ȝȒțȠȣȢ 20 ȤĮȡĮțIJȒȡȦȞ ȝİ ȩȞȠȝĮ st.

x

ǻȫıIJİ IJȘȞ IJȚȝȒ 1.4 ıIJȘȞ ȝİIJĮȕȜȘIJȒ x țĮȚ IJȘȞ IJȚȝȒ 'O ĮȡȚșȝȩȢ ʌȠȣ įȫıĮIJİ İȓȞĮȚ Ƞ ' ıIJȘȞ ȝİIJĮȕȜȘIJȒ st.

x

ǼțIJȣʌȫıIJİ ıIJȘȞ ȠșȩȞȘ IJȚȢ ȝİIJĮȕȜȘIJȑȢ st țĮȚ x ȤȡȘıȚȝȠʌȠȚȫȞIJĮȢ įȪȠ İȞIJȠȜȑȢ Write.

x

ȆȠȓȠ șĮ ȒIJĮȞ IJȠ ĮʌȠIJȑȜİıȝĮ IJȘȢ İțIJȪʌȦıȘȢ İȐȞ ȤȡȘıȚȝȠʌȠȚȠȪıĮIJİ įȪȠ İȞIJȠȜȑȢ Writeln;

x

ȆȫȢ ȝʌȠȡİȓIJİ ȞĮ İțIJȣʌȫıİIJİ IJȠ ȓįȚȠ ȝȒȞȣȝĮ ıIJȘȞ ȠșȩȞȘ ȝİ IJȘȞ ȤȡȒıȘ ȝȓĮȢ ȝȩȞȠ İȞIJȠȜȒȢ;

DZıțȘıȘ 2.2 x

ȉȡȠʌȠʌȠȚȒıIJİ IJȠ ʌȡȩȖȡĮȝȝĮ IJȘȢ ʌȡȠȘȖȠȪȝİȞȘȢ ȐıțȘıȘȢ ȫıIJİ Ș İțIJȪʌȦıȘ IJȘȢ ȝİIJĮȕȜȘIJȒȢ x ȞĮ ȖȓȞİȚ ȝİ 3 įİțĮįȚțȐ ȥȘijȓĮ țĮȚ ıȣȞȠȜȚțȩ İȪȡȠȢ 10 ȥȘijȓĮ, ıȫıIJİ IJȠ ȞȑȠ ʌȡȩȖȡĮȝȝĮ ȝİ ȩȞȠȝĮ ex22.pas.

x

TȚ ʌĮȡĮIJȘȡİȓIJİ ĮȞ IJȡȠʌȠʌȠȚȒıİIJİ IJȠ İȪȡȠȢ İțIJȪʌȦıȘȢ IJȘȢ ĮȜijĮȡȚșȝȘIJȚțȒȢ ȝİIJĮȕȜȘIJȒȢ st;

x

ȉȚ șĮ ȖȓȞİȚ İȐȞ ȠȡȓıİIJİ IJȠ İȪȡȠȢ İțIJȪʌȦıȘȢ IJȘȢ ȝİIJĮȕȜȘIJȒȢ x ȝȚțȡȩIJİȡȠ Įʌȩ IJȠȞ ĮȡȚșȝȩ IJȦȞ įİțĮįȚțȫȞ ȥȘijȓȦȞ (ʌ.Ȥ. x:1:3);


ǹʌȜȐ ȆȡȠȖȡȐȝȝĮIJĮ

15

DZıțȘıȘ 2.3 x

īȡȐȥIJİ ʌȡȩȖȡĮȝȝĮ, ex23.pas, IJȠ ȠʌȠȓȠ ȞĮ ȗȘIJȐ Įʌȩ IJȠȞ ȤȡȒıIJȘ ȞĮ İȚıȐȖİȚ 6 ʌȡĮȖȝĮIJȚțȠȪȢ ĮȡȚșȝȠȪȢ țĮȚ ıIJȘȞ ıȣȞȑȤİȚĮ ȞĮ IJȠȣȢ İțIJȣʌȫȞİȚ ıIJȘȞ ȠșȩȞȘ (ȤȡȘıȚȝȠʌȠȚȒıIJİ įȚĮijȠȡİIJȚțȑȢ ȝİIJĮȕȜȘIJȑȢ ȖȚĮ IJȠȞ țȐșİ ĮȡȚșȝȩ).

x

ȆȫȢ ȝʌȠȡİȓIJİ ȞĮ IJȣʌȫıİIJİ IJȠȣȢ ĮȡȚșȝȠȪȢ ĮȣIJȠȪȢ ıİ IJȡİȚȢ ȖȡĮȝȝȑȢ (įȪȠ ıİ țȐșİ ȖȡĮȝȝȒ) ıIJȠȚȤȚıȝȑȞȠȣȢ ıİ ıIJȒȜİȢ;

x

ȉȚ ʌĮȡĮIJȘȡİȓIJİ İȐȞ ȤȡȘıȚȝȠʌȠȚȒıİIJİ IJȚȢ İȞIJȠȜȑȢ Readln țĮȚ Writeln ȤȦȡȓȢ ʌĮȡİȞșȑıİȚȢ țĮȚ ȠȡȓıȝĮIJĮ;

DZıțȘıȘ 2.4 īȡȐȥIJİ ʌȡȩȖȡĮȝȝĮ, ex24.pas, IJȠ ȠʌȠȓȠ ȗȘIJȐ Įʌȩ IJȠȞ ȤȡȒıIJȘ ȞĮ İȚıȐȖİȚ IJȠ ȩȞȠȝĮ, IJȠ İʌȫȞȣȝȠ, IJȠ İȟȐȝȘȞȠ (İĮȡȚȞȩ Ȓ ȤİȚȝİȡȚȞȩ) țĮȚ IJȠ ȑIJȠȢ İȞȩȢ ıʌȠȣįĮıIJȒ. ȈIJȘȞ ıȣȞȑȤİȚĮ ȞĮ İțIJȣʌȫȞİȚ ıIJȘȞ ȠșȩȞȘ IJȘȞ ʌĮȡĮțȐIJȦ ȕİȕĮȓȦıȘ: T.Ǽ.I. ȁĮȝȓĮȢ Ȉ.ȉ.Ǽĭ. ȉȝȒȝĮ ȆȜȘȡȠijȠȡȚțȒȢ & ȉİȤȞȠȜȠȖȓĮȢ Ǿ/Ȋ ǺİȕĮȚȫȞİIJĮȚ ȩIJȚ Ƞ ıʌȠȣįĮıIJȒȢ (ȩȞȠȝĮ) (İʌȫȞȣȝȠ) ȑȤİȚ İȖȖȡĮijİȓ ıIJȠ ȉȝȒȝĮ ȆȜȘȡȠijȠȡȚțȒȢ & ȉİȤȞȠȜȠȖȓĮȢ IJȠȣ ȉ.Ǽ.ǿ. ȁĮȝȓĮȢ ȖȚĮ IJȠ (İȟȐȝȘȞȠ) İȟȐȝȘȞȠ IJȠȣ (ȑIJȠȢ). ȩʌȠȣ (ȩȞȠȝĮ), (İʌȫȞȣȝȠ), (İȟȐȝȘȞȠ) țĮȚ (ȑIJȠȢ), İȓȞĮȚ IJĮ ıIJȠȚȤİȓĮ ʌȠȣ İȚıȐȖİȚ Ƞ ȤȡȒıIJȘȢ.

ȈǾȂǼǿȍȈǼǿȈ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________

ǹș. Ǽ. ȀȠȣIJıȠȞȚțȩȜĮȢ


16

ǹȈȀǾȈǾ 2

_____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________


17

ǹȈȀǾȈǾ 3 ȊʌȠȜȠȖȚıȝȠȓ ȉȚȝȫȞ 3.1 ǼȚıĮȖȦȖȒ ȋȡȘıȚȝȠʌȠȚȫȞIJĮȢ ıİ ȑȞĮ ʌȡȩȖȡĮȝȝĮ IJȘȢ Pascal IJȚȢ IJȚȝȑȢ țȐʌȠȚȦȞ ȝİIJĮȕȜȘIJȫȞ, țȐʌȠȚİȢ ıIJĮșİȡȑȢ IJȚȝȑȢ țĮȚ ȝİ IJȘȞ ȕȠȒșİȚĮ įȚȐijȠȡȦȞ ĮȡȚșȝȘIJȚțȫȞ IJİȜİıIJȫȞ țĮȚ ıȣȞĮȡIJȒıİȦȞ ʌȠȣ ȝĮȢ ʌĮȡȑȤİȚ Ș ȖȜȫııĮ, ȝʌȠȡȠȪȝİ ȞĮ ȣʌȠȜȠȖȓıȠȣȝİ IJȚȢ IJȚȝȑȢ įȚȐijȠȡȦȞ ĮȡȚșȝȘIJȚțȫȞ ʌĮȡĮıIJȐıİȦȞ. 3.2 ȈIJĮșİȡȑȢ ȈȣȤȞȐ ıİ ʌȠȜȜȐ ʌȡȠȖȡȐȝȝĮIJĮ șĮ ȤȡİȚĮȗȩȝĮıIJİ țȐʌȠȚİȢ ʌȠıȩIJȘIJİȢ (ĮȡȚșȝȠȪȢ, ȤĮȡĮțIJȒȡİȢ ț.Ȝ.ʌ.) ȠȚ ȠʌȠȓİȢ įİ șĮ ĮȜȜȐȗȠȣȞ țĮș’ȩȜȘ IJȘ įȚȐȡțİȚĮ IJȘȢ İțIJȑȜİıȒȢ IJȠȣ. ȈIJȚȢ ʌȠıȩIJȘIJİȢ ĮȣIJȑȢ ȝʌȠȡȠȪȝİ ȞĮ įȫıȠȣȝİ ȑȞĮ ȩȞȠȝĮ țĮȚ ıIJȘ ıȣȞȑȤİȚĮ ȠʌȠȣįȒʌȠIJİ ȝȑıĮ ıIJȠ ʌȡȩȖȡĮȝȝĮ ȝʌȠȡȠȪȝİ ȞĮ ȤȡȘıȚȝȠʌȠȚȠȪȝİ IJȠ ȩȞȠȝĮ ĮȣIJȩ ĮȞIJȓ IJȘȢ IJȚȝȒȢ IJȘȢ ʌȠıȩIJȘIJĮȢ. ȅȚ ʌȠıȩIJȘIJİȢ ĮȣIJȑȢ ȜȑȖȠȞIJĮȚ ıIJĮșİȡȑȢ (constants). īȚĮ ʌĮȡȐįİȚȖȝĮ ȝʌȠȡȠȪȝİ ȞĮ țĮșȠȡȓıȠȣȝİ IJȘȞ IJȚȝȒ IJȠȣ 'ʌ' ȓıȘ ȝİ 3.1415926535898 țĮȚ ȞĮ IJȘ ȤȡȘıȚȝȠʌȠȚȠȪȝİ ȝȑıĮ ıIJȠ ʌȡȩȖȡĮȝȝĮ, ȩIJĮȞ IJȘ ȤȡİȚĮȗȩȝĮıIJİ, ȑȤȠȞIJĮȢ ȣʌȩȥȘ ȝĮȢ ȩIJȚ ĮȣIJȒ İȓȞĮȚ ıȣȞİȤȫȢ įȚĮșȑıȚȝȘ țĮȚ ȠȡșȒ. Ǿ įȒȜȦıȘ IJȦȞ ıIJĮșİȡȫȞ İȞȩȢ ʌȡȠȖȡȐȝȝĮIJȠȢ ȖȓȞİIJĮȚ ıIJȠ IJȝȒȝĮ įȘȜȫıİȦȞ ȝİ IJȘȞ İȞIJȠȜȒ įȒȜȦıȘȢ ıIJĮșİȡȫȞ (constant declaration) Ș ȠʌȠȓĮ ȑȤİȚ IJȘ ȝȠȡijȒ: Const ȩȞȠȝĮ_ıIJĮșİȡȐȢ1 = IJȚȝȒ1; ȩȞȠȝĮ_ıIJĮșİȡȐȢ2 = IJȚȝȒ2; .. .. .. .. ȩȞȠȝĮ_ıIJĮșİȡȐȢn = IJȚȝȒn; ȩʌȠȣ Const İȓȞĮȚ Ș įİıȝİȣȝȑȞȘ ȜȑȟȘ ʌȠȣ ȤȡȘıȚȝȠʌȠȚİȓIJĮȚ ȖȚĮ IJȘ įȒȜȦıȘ IJȦȞ ıIJĮșİȡȫȞ, ȩȞȠȝĮ_ıIJĮșİȡȐȢi İȓȞĮȚ IJȠ ȩȞȠȝĮ IJȘȢ i-ȠıIJȒȢ ıIJĮșİȡȐȢ țĮȚ IJȚȝȒi Ș ĮȞIJȓıIJȠȚȤȘ IJȚȝȒ IJȘȢ. ȆĮȡȐįİȚȖȝĮ: Program Constants; Const MyMessage = 'Welcome'; Pi = 3.141592654; MyChar = 'T'; MyInteger = 4578; Var X: Integer; Begin X := 15; Writeln(MyMessage); Writeln(Pi); Writeln(MyChar); Writeln(MyInteger); Writeln(X); End.

{ǹȜijĮȡȚșȝȘIJȚțȒ ıIJĮșİȡȐ} {ȆȡĮȖȝĮIJȚțȒ ıIJĮșİȡȐ} {ȈIJĮșİȡȐ ȤĮȡĮțIJȒȡĮ} {ǹțȑȡĮȚĮ ıIJĮșİȡȐ}


18

ǹȈȀǾȈǾ 3

3.3 ǹȡȚșȝȘIJȚțȠȓ ȉİȜİıIJȑȢ ȆȡȐȟİȚȢ ȝİ ʌȡĮȖȝĮIJȚțȠȪȢ ĮȡȚșȝȠȪȢ Ǿ Pascal įȚĮșȑIJİȚ IJȠȣȢ ʌĮȡĮțȐIJȦ IJİȜİıIJȑȢ ȖȚĮ IJȘȞ İțIJȑȜİıȘ ĮȡȚșȝȘIJȚțȫȞ ʌȡȐȟİȦȞ ȝİ ʌȡĮȖȝĮIJȚțȠȪȢ ĮȡȚșȝȠȪȢ: + * /

ȖȚĮ IJȘȞ ʌȡȩıșİıȘ ȖȚĮ IJȘȞ ĮijĮȓȡİıȘȢ ȖȚĮ IJȠȞ ʌȠȜȜĮʌȜĮıȚĮıȝȩ ȖȚĮ IJȘȞ įȚĮȓȡİıȘ

ȆĮȡȐįİȚȖȝĮ: Program Calculations; Var x,y,z : Real; Begin y := 1.14 + 3.45; x := 3.14 * 2 * y; z := (x + y) / (x - y); Writeln('x = ', x:6:2, ' y = ', y:6:2, ' z= ', z:6:2); End. ȆȡȐȟİȚȢ ȝİ ĮțȑȡĮȚȠȣȢ ĮȡȚșȝȠȪȢ ȅȚ IJİȜİıIJȑȢ ȖȚĮ IJȘȞ İțIJȑȜİıȘ ĮȡȚșȝȘIJȚțȫȞ ʌȡȐȟİȦȞ ȝİIJĮȟȪ ĮțİȡĮȓȦȞ İȓȞĮȚ ȠȚ ʌĮȡĮțȐIJȦ: + * / DIV MOD

ȖȚĮ IJȘȞ ʌȡȩıșİıȘ ȖȚĮ IJȘȞ ĮijĮȓȡİıȘ ȖȚĮ IJȠȞ ʌȠȜȜĮʌȜĮıȚĮıȝȩ ȖȚĮ IJȘȞ įȚĮȓȡİıȘ (IJȠ ĮʌȠIJȑȜİıȝĮ İȓȞĮȚ ʌȡĮȖȝĮIJȚțȩȢ ĮȡȚșȝȩȢ) ȖȚĮ IJȠ ĮțȑȡĮȚȠ ʌȘȜȓțȠ IJȘȢ įȚĮȓȡİıȘȢ ȖȚĮ IJȠ ĮțȑȡĮȚȠ ȣʌȩȜȠȚʌȠ IJȘȢ įȚĮȓȡİıȘȢ

ȅȚ IJİȜİıIJȑȢ ȖȚĮ IJȠȣȢ ĮțȑȡĮȚȠȣȢ ĮȡȚșȝȠȪȢ İȓȞĮȚ ȓįȚȠȚ ȝİ IJȠȣ IJİȜİıIJȑȢ IJȦȞ ʌȡĮȖȝĮIJȚțȫȞ ĮȡȚșȝȫȞ, İțIJȩȢ Įʌȩ IJȠȣȢ IJİȜİıIJȑȢ IJȘȢ įȚĮȓȡİıȘȢ. īȚĮ IJȘȞ ĮțȑȡĮȚĮ įȚĮȓȡİıȘ ȤȡȘıȚȝȠʌȠȚİȓIJĮȚ Ƞ IJİȜİıIJȒȢ DIV Ƞ ȠʌȠȓȠȢ ȝĮȢ įȓȞİȚ IJȠ ĮțȑȡĮȚȠ ʌȘȜȓțȠ IJȘȢ įȚĮȓȡİıȘȢ, țĮȚ Ƞ IJİȜİıIJȒȢ MOD Ƞ ȠʌȠȓȠȢ ȝĮȢ įȓȞİȚ IJȠ ĮțȑȡĮȚȠ ȣʌȩȜȠȚʌȠ IJȘȢ įȚĮȓȡİıȘȢ. ȆĮȡĮįİȓȖȝĮIJĮ: Ǿ IJȚȝȒ IJȘȢ ʌĮȡȐıIJĮıȘȢ 7 DIV 3 İȓȞĮȚ ȓıȘ ȝİ 2 Ǿ IJȚȝȒ IJȘȢ ʌĮȡȐıIJĮıȘȢ 7 MOD 3 İȓȞĮȚ ȓıȘ ȝİ 1 ȅȚ IJİȜİıIJȑȢ DIV țĮȚ MOD įİȞ ȝʌȠȡȠȪȞ ȞĮ ȤȡȘıȚȝȠʌȠȚȘșȠȪȞ ȖȚĮ ʌȡĮȖȝĮIJȚțȠȪȢ ĮȡȚșȝȠȪȢ. (ȑIJıȚ, ʌ.Ȥ., Ș ʌĮȡȐıIJĮıȘ 13.12 MOD 4 İȓȞĮȚ ȜȐșȠȢ) Ǿ Pascal İʌȚIJȡȑʌİȚ IJȘȞ ĮȞȐȝȚȟȘ ʌȡĮȖȝĮIJȚțȫȞ ĮȡȚșȝȫȞ țĮȚ ĮțİȡĮȓȦȞ ıİ ĮȡȚșȝȘIJȚțȑȢ ʌȡȐȟİȚȢ. ȉȠ ĮʌȠIJȑȜİıȝĮ IJȠ ȠʌȠȓȠ İʌȚıIJȡȑijİIJĮȚ ıİ ĮȣIJȒ IJȘȞ ʌİȡȓʌIJȦıȘ İȓȞĮȚ ʌȐȞIJĮ ʌȡĮȖȝĮIJȚțȩȢ ĮȡȚșȝȩȢ: X:=(3*48.5) / 3; ȉȠ X (ʌȠȣ șĮ ʌȡȑʌİȚ ȞĮ İȓȞĮȚ Real) ʌĮȓȡȞİȚ IJȘȞ IJȚȝȒ 48.5 Y:=7/3; ȉȠ Y (ʌȠȣ șĮ ʌȡȑʌİȚ ȞĮ İȓȞĮȚ Real) ʌĮȓȡȞİȚ IJȘȞ IJȚȝȒ 2.333333


ȊʌȠȜȠȖȚıȝȠȓ ȉȚȝȫȞ

19

ȋȡȒıȘ ʌĮȡİȞșȑıİȦȞ - ʌȡȠIJİȡĮȚȩIJȘIJĮ IJİȜİıIJȫȞ Ǿ Pascal țĮIJȐ IJȘȞ İțIJȑȜİıȘ IJȦȞ ʌȡȐȟİȦȞ ıIJȚȢ ĮȡȚșȝȘIJȚțȑȢ ʌĮȡĮıIJȐıİȚȢ, IJȘȡİȓ IJȘȞ ʌȡȠIJİȡĮȚȩIJȘIJĮ ʌȠȣ İȓȞĮȚ ȖȞȦıIJȒ Įʌȩ IJĮ ȝĮșȘȝĮIJȚțȐ. ȈIJȘȞ ʌĮȡĮțȐIJȦ ʌĮȡȐıIJĮıȘ: 1 + 3.5*8 - 45/9 ʌȡȫIJĮ İțIJİȜİȓIJĮȚ Ƞ ʌȠȜȜĮʌȜĮıȚĮıȝȩȢ, ıIJȘȞ ıȣȞȑȤİȚĮ Ș įȚĮȓȡİıȘ ıIJȘȞ ıȣȞȑȤİȚĮ Ș ʌȡȩıșİıȘ țĮȚ IJİȜİȣIJĮȓĮ Ș ĮijĮȓȡİıȘ. ȅȚ IJİȜİıIJȑȢ *, /, DIV, MOD İȓȞĮȚ ȚıȠįȪȞĮȝȠȚ ȝİIJĮȟȪ IJȠȣȢ țĮȚ ȑȤȠȣȞ ȝİȖĮȜȪIJİȡȘ ʌȡȠIJİȡĮȚȩIJȘIJĮ Įʌȩ IJȠȣȢ IJİȜİıIJȑȢ + țĮȚ -. ǵIJĮȞ ıİ țȐʌȠȚĮ ʌĮȡȐıIJĮıȘ ȣʌȐȡȤȠȣȞ IJİȜİıIJȑȢ ȝİ IJȘȞ ȓįȚĮ ʌȡȠIJİȡĮȚȩIJȘIJĮ IJȩIJİ ȠȚ ʌȡȐȟİȚȢ ȖȓȞȠȞIJĮȚ Įʌȩ ĮȡȚıIJİȡȐ ʌȡȠȢ IJĮ įİȟȚȐ. ǼȐȞ ıIJȘȞ ʌĮȡĮʌȐȞȦ ʌĮȡȐıIJĮıȘ İʌȚșȣȝȠȪıĮȝİ Ș įȚĮȓȡİıȘ ȝİ IJȠ 9 ȞĮ ȖȓȞİȚ IJİȜİȣIJĮȓĮ, IJȩIJİ șĮ ȑʌȡİʌİ ȞĮ ȤȡȘıȚȝȠʌȠȚȒıȠȣȝİ ʌĮȡİȞșȑıİȚȢ, ȠʌȩIJİ Ș ʌĮȡȐıIJĮıȘ șĮ ȖȚȞȩIJĮȞ: (1 + 3.5*8 -45) / 9 ǼȓȞĮȚ İʌȓıȘȢ įȣȞĮIJȒ Ș ȑȞșİıȘ ʌĮȡȑȞșİıȘȢ İȞIJȩȢ ȐȜȜȘȢ ʌĮȡȑȞșİıȘȢ. ȈIJȘȞ ʌĮȡĮʌȐȞȦ ʌĮȡȐıIJĮıȘ İȐȞ İʌȚșȣȝȠȪıĮȝİ Ș ʌȡȩıșİıȘ ȞĮ İțIJİȜİıIJİȓ ʌȡȚȞ IJȠ ʌȠȜȜĮʌȜĮıȚĮıȝȩ, IJȩIJİ Ș ʌĮȡȐıIJĮıȘ șĮ ȖȚȞȩIJĮȞ: ((1 + 3.5)*8 - 45) /9 3.4 ȈȣȞĮȡIJȒıİȚȢ țĮȚ įȚĮįȚțĮıȓİȢ IJȘȢ Pascal ȂĮșȘȝĮIJȚțȑȢ țĮȚ IJȡȚȖȦȞȠȝİIJȡȚțȑȢ ıȣȞĮȡIJȒıİȚȢ ǼțIJȩȢ IJȦȞ IJİȜİıIJȫȞ, Ș Pascal įȚĮșȑIJİȚ țĮȚ IJȚȢ ʌĮȡĮțȐIJȦ ıȣȞĮȡIJȒıİȚȢ: Abs(x)

ǼʌȚıIJȡȑijİȚ IJȘȞ ĮʌȩȜȣIJȘ IJȚȝȒ İȞȩȢ ĮțȑȡĮȚȠȣ Ȓ ʌȡĮȖȝĮIJȚțȠȪ ĮȡȚșȝȠȪ x. Ǿ İʌȚıIJȡİijȩȝİȞȘ IJȚȝȒ İȓȞĮȚ IJȠȣ ȓįȚȠȣ IJȪʌȠȣ ȝİ IJȠ x.

Sqr(x)

ǼʌȚıIJȡȑijİȚ IJȠ IJİIJȡȐȖȦȞȠ İȞȩȢ ĮțȑȡĮȚȠȣ Ȓ ʌȡĮȖȝĮIJȚțȠȪ ĮȡȚșȝȠȪ x. Ǿ İʌȚıIJȡİijȩȝİȞȘ IJȚȝȒ İȓȞĮȚ IJȠȣ ȓįȚȠȣ IJȪʌȠȣ ȝİ IJȠ x.

Sqrt(x)

ǼʌȚıIJȡȑijİȚ IJȘȞ IJİIJȡĮȖȦȞȚțȒ ȡȓȗĮ İȞȩȢ ĮțȑȡĮȚȠȣ Ȓ ʌȡĮȖȝĮIJȚțȠȪ ĮȡȚșȝȠȪ x. Ǿ İʌȚıIJȡİijȩȝİȞȘ IJȚȝȒ İȓȞĮȚ ʌȡĮȖȝĮIJȚțȩȢ ĮȡȚșȝȩȢ.

Exp(x)

ǼʌȚıIJȡȑijİȚ IJȠ ex. Ǿ İʌȚıIJȡİijȩȝİȞȘ IJȚȝȒ İȓȞĮȚ ʌȡĮȖȝĮIJȚțȩȢ ĮȡȚșȝȩȢ.

Ln(x)

ǼʌȚıIJȡȑijİȚ IJȠ ȜȠȖȐȡȚșȝȠ İȞȩȢ șİIJȚțȠȪ ĮțȑȡĮȚȠȣ Ȓ ʌȡĮȖȝĮIJȚțȠȪ ĮȡȚșȝȠȪ x. Ǿ İʌȚıIJȡİijȩȝİȞȘ IJȚȝȒ İȓȞĮȚ ʌȡĮȖȝĮIJȚțȩȢ ĮȡȚșȝȩȢ.

Int(x)

ǼʌȚıIJȑijİȚ IJȠ ĮțȑȡĮȚȠ ȝȑȡȠȢ İȞȩȢ ʌȡĮȖȝĮIJȚțȠȪ İʌȚıIJȡİijȩȝİȞȘ IJȚȝȒ İȓȞĮȚ ʌȡĮȖȝĮIJȚțȩȢ ĮȡȚșȝȩȢ.

Trunc(x)

ǹʌȠțȩʌIJİȚ IJȠ įİțĮįȚțȩ ȝȑȡȠȢ İȞȩȢ ʌȡĮȖȝĮIJȚțȠȪ ĮȡȚșȝȠȪ x. Ǿ İʌȚıIJȡİijȩȝİȞȘ IJȚȝȒ İȓȞĮȚ ĮțȑȡĮȚȠȢ ĮȡȚșȝȩȢ.

Round(x)

ȈIJȡȠȖȖȣȜȠʌȠȚİȓ ȑȞĮȞ ʌȡĮȖȝĮIJȚțȩ ĮȡȚșȝȩ x. Ǿ İʌȚıIJȡİijȩȝİȞȘ IJȚȝȒ İȓȞĮȚ ĮțȑȡĮȚȠȢ ĮȡȚșȝȩȢ.

Frac(x)

ǼʌȚıIJȡȑijİȚ IJȠ įİțĮįȚțȩ ȝȑȡȠȢ İȞȩȢ ʌȡĮȖȝĮIJȚțȠȪ ĮȡȚșȝȠȪ x. Ǿ İʌȚıIJȡİijȩȝİȞȘ IJȚȝȒ İȓȞĮȚ ʌȡĮȖȝĮIJȚțȩȢ ĮȡȚșȝȩȢ.

Sin(x)

ǼʌȚıIJȡȑijİȚ IJȠ ȘȝȓIJȠȞȠ ȝȚĮȢ ȖȦȞȓĮȢ x Ș ȠʌȠȓĮ ʌȡȑʌİȚ ȞĮ įȓȞİIJĮȚ ıİ ĮțIJȓȞȚĮ. Ǿ İʌȚıIJȡİijȩȝİȞȘ IJȚȝȒ İȓȞĮȚ ʌȡĮȖȝĮIJȚțȩȢ ĮȡȚșȝȩȢ.

Cos(x)

ǼʌȚıIJȡȑijİȚ IJȠ ıȣȞȘȝȓIJȠȞȠ ȝȚĮȢ ȖȦȞȓĮȢ x Ș ȠʌȠȓĮ ʌȡȑʌİȚ ȞĮ įȓȞİIJĮȚ ıİ ĮțIJȓȞȚĮ. Ǿ İʌȚıIJȡİijȩȝİȞȘ IJȚȝȒ İȓȞĮȚ ʌȡĮȖȝĮIJȚțȩȢ ĮȡȚșȝȩȢ.

Arctan(x)

ǼʌȚıIJȡȑijİȚ IJȠ IJȩȟȠ ʌȠȣ ȑȤİȚ İijĮʌIJȠȝȑȞȘ x. Ǿ İʌȚıIJȡİijȩȝİȞȘ IJȚȝȒ İȓȞĮȚ ʌȡĮȖȝĮIJȚțȩȢ ĮȡȚșȝȩȢ.

ǹș. Ǽ. ȀȠȣIJıȠȞȚțȩȜĮȢ

ĮȡȚșȝȠȪ

x.

Ǿ


20

ǹȈȀǾȈǾ 3

ȆĮȡȐįİȚȖȝĮ: Program Functions; Var x, y : Real; Begin x := Sqrt(100); y := Sqr(x); Writeln(x,y); End. ȈȣȞĮȡIJȒıİȚȢ & įȚĮįȚțĮıȓİȢ IJĮțIJȚțȫȞ IJȪʌȦȞ ǹʌȩ IJȠȣȢ IJȪʌȠȣȢ IJȘȢ Pascal, ʌȠȣ ȑȤȠȣȝİ įİȚ ȝȑȤȡȚ IJȫȡĮ, IJĮțIJȚțȠȓ IJȪʌȠȚ İȓȞĮȚ: Ƞ ĮțȑȡĮȚȠȢ (Integer), Ƞ ȜȠȖȚțȩȢ (Boolean) țĮȚ Ƞ IJȪʌȠȢ ȤĮȡĮțIJȒȡĮ (Char). ȋĮȡĮțIJȘȡȚıIJȚțȐ IJȦȞ IJĮțIJȚțȫȞ IJȪʌȦȞ İȓȞĮȚ: x

ȅȚ IJȚȝȑȢ İȓȞĮȚ ĮʌȜȑȢ (įȘȜĮįȒ įİȞ ĮʌȠIJİȜȠȪȞIJĮȚ Įʌȩ ıȪȞșİıȘ ȐȜȜȦȞ IJȚȝȫȞ).

x

ȅȚ IJȚȝȑȢ IJȠȣȢ İȓȞĮȚ įȚĮIJİIJĮȖȝȑȞİȢ.

x

ȀȐșİ IJȚȝȒ ȑȤİȚ ȝȓĮ ȝȠȞĮįȚțȒ ʌȡȠȘȖȠȪȝİȞȘ IJȚȝȒ (İțIJȩȢ Įʌȩ IJȘȞ ʌȡȫIJȘ) țĮȚ ȝȓĮ ȝȠȞĮįȚțȒ İʌȩȝİȞȘ (İțIJȩȢ Įʌȩ IJȘȞ IJİȜİȣIJĮȓĮ).

x

ȀȐșİ IJȚȝȒ ĮȞIJȚıIJȠȚȤİȓ ıİ ȑȞĮȞ ĮțȑȡĮȚȠ Ƞ ȠʌȠȓȠȢ ʌĮȡȚıIJȐ IJȘȞ ĮȪȟȠȣıĮ șȑıȘ IJȘȢ IJȚȝȒȢ ȝȑıĮ ıIJȠ ıȪȞȠȜȠ IJȦȞ IJȚȝȫȞ. ȈȘȝİȚȫıIJİ ȩIJȚ ıIJȘȞ ʌȡȫIJȘ IJȚȝȒ ĮȞIJȚıIJȠȚȤİȓ Ƞ ĮȡȚșȝȩȢ ȝȘįȑȞ.

DzIJıȚ, ȖȚĮ ʌĮȡȐįİȚȖȝĮ, Ș ĮȪȟȠȣıĮ șȑıȘ IJȠȣ ȤĮȡĮțIJȒȡĮ '7' İȓȞĮȚ Ƞ ĮȡȚșȝȩȢ 55 (țȦįȚțȩȢ ASCII, ȕȜȑʌİ ȆĮȡȐȡIJȘȝĮ ǹ'), Ƞ ʌȡȠȘȖȠȪȝİȞȠȢ ȤĮȡĮțIJȒȡĮȢ İȓȞĮȚ Ƞ '6' țĮȚ Ƞ İʌȩȝİȞȠȢ ȤĮȡĮțIJȒȡĮȢ İȓȞĮȚ Ƞ '8' Ȃİ IJȚȢ ʌĮȡĮțȐIJȦ ıȣȞĮȡIJȒıİȚȢ țĮȚ įȚĮįȚțĮıȓİȢ ȝʌȠȡȠȪȝİ ȞĮ įȚĮȤİȚȡȚıșȠȪȝİ IJĮțIJȚțȠȪȢ IJȪʌȠȣȢ: Chr(x)

ǼʌȚıIJȡȑijİȚ IJȠ ȤĮȡĮțIJȒȡĮ ASCII ʌȠȣ ĮȞIJȚıIJȠȚȤİȓ ıIJȠȞ ĮțȑȡĮȚȠ x.

Ord(x)

ǼʌȚıIJȡȑijİȚ IJȠȞ ĮțȑȡĮȚȠ ȠʌȠȓȠȢ ĮȞIJȚıIJȠȚȤİȓ ıIJȠ x, țĮȚ įİȓȤȞİȚ IJȘȞ ĮȪȟȠȣıĮ șȑıȘ IJȠȣ x ȝȑıĮ ıIJȠ ıȪȞȠȜȠ IJȚȝȫȞ.

Succ(x)

ǼʌȚıIJȡȑijİȚ IJȘȞ İʌȩȝİȞȘ IJȚȝȒ IJȠȣ x.

Pred(x)

ǼʌȚıIJȡȑijİȚ IJȘȞ ʌȡȠȘȖȠȪȝİȞȘ IJȚȝȒ IJȠȣ x.

Inc(x,i)

ǹȣȟȐȞİȚ IJȘȞ IJȚȝȒ IJȠȣ x țĮIJȐ i 'ȝȠȞȐįİȢ'.

Dec(x,i)

ȂİȚȫȞİȚ IJȘȞ IJȚȝȒ IJȠȣ x țĮIJȐ i 'ȝȠȞȐįİȢ'.

ȆĮȡĮįİȓȖȝĮIJĮ: Ord('7')

İʌȚıIJȡȑijİȚ IJȘȞ IJȚȝȒ 55 (ȕȜȑʌİ ȆĮȡȐȡIJȘȝĮ ǹ')

Chr(55)

İʌȚıIJȡȑijİȚ IJȠȞ ȤĮȡĮțIJȒȡĮ '7'

Pred('7')

İʌȚıIJȡȑijİȚ IJȠȞ ȤĮȡĮțIJȒȡĮ '6'

Succ('7')

İʌȚıIJȡȑijİȚ IJȠȞ ȤĮȡĮțIJȒȡĮ '8'

x:='F'; Inc(x,4)

įȓȞİȚ ıIJȠ x IJȘȞ IJȚȝȒ 'J'

x:='7'; Dec(x,2)

įȓȞİȚ ıIJȠ x IJȘȞ IJȚȝȒ 5


ȊʌȠȜȠȖȚıȝȠȓ ȉȚȝȫȞ

21

3.5 ǹıțȒıİȚȢ DZıțȘıȘ 3.1 ȃĮ ȖȡĮijİȓ ʌȡȩȖȡĮȝȝĮ, ex31.pas, IJȠ ȠʌȠȓȠ ȞĮ ȗȘIJȐİȚ IJȘȞ ʌȠıȩIJȘIJĮ Įʌȩ ȑȞĮ ʌȡȠȧȩȞ ʌȠȣ ĮȖȠȡȐȗȠȣȝİ țĮșȫȢ țĮȚ IJȘȞ IJȚȝȒ ȝȠȞȐįĮȢ țĮȚ ıIJȘȞ ıȣȞȑȤİȚĮ ȞĮ ȣʌȠȜȠȖȓȗİȚ IJȠ IJİȜȚțȩ ʌȠıȩ ʌȠȣ șĮ ʌȜȘȡȫıȠȣȝİ ıȣȞȣʌȠȜȠȖȓȗȠȞIJĮȢ ĭȆǹ 18%. Ǿ ȠșȩȞȘ İȚıĮȖȦȖȒȢ țĮȚ İȝijȐȞȚıȘȢ ıIJȠȚȤİȓȦȞ ȞĮ İȓȞĮȚ ȩʌȦȢ ʌĮȡĮțȐIJȦ (IJĮ įİįȠȝȑȞĮ ʌȠȣ İȚıȐȖİȚ Ƞ ȤȡȒıIJȘȢ İȝijĮȞȓȗȠȞIJĮȚ ȝİ ȑȞIJȠȞĮ ıIJȠȚȤİȓĮ):

ǻȫıİ IJȘȞ ʌȠıȩIJȘIJĮ : 4 ǻȫıİ IJȘȞ IJȚȝȒ ȝȠȞȐįĮȢ : 654 ȉȠ țȩıIJȠȢ IJȦȞ 4 IJİȝĮȤȓȦȞ İȓȞĮȚ : 2616 ȅ ĭȆǹ İȓȞĮȚ : 470.88 ȉȠ ıȣȞȠȜȚțȩ țȩıIJȠȢ İȓȞĮȚ : 3086.88

DZıțȘıȘ 3.2 ȃĮ ȖȡĮijİȓ ʌȡȩȖȡĮȝȝĮ, ex32.pas, ʌȠȣ ȞĮ įȚĮȕȐȗİȚ Įʌȩ IJȠ ʌȜȘțIJȡȠȜȩȖȚȠ ȑȞĮ IJİIJȡĮȥȒijȚȠ ijȣıȚțȩ ĮȡȚșȝȩ țĮȚ ȞĮ ȕȡȓıțİȚ țĮȚ ȞĮ İȝijĮȞȓȗİȚ ıIJȘȞ ȠșȩȞȘ IJȠȞ ĮȞȐıIJȡȠijȩ IJȠȣ (ʌ.Ȥ. Ƞ ĮȞȐıIJȡȠijȠȢ IJȠȣ 1234 İȓȞĮȚ Ƞ 4321). ĬİȦȡȠȪȝİ ȩIJȚ IJĮ įİįȠȝȑȞĮ ʌȠȣ įȓȞȠȞIJĮȚ Įʌȩ IJȠ ʌȜȘțIJȡȠȜȩȖȚȠ İȓȞĮȚ ıȦıIJȐ. DZıțȘıȘ 3.3 ȃĮ ȖȡĮijİȓ ʌȡȩȖȡĮȝȝĮ, ex33.pas, ʌȠȣ ȞĮ įȚĮȕȐȗİȚ Įʌȩ IJȠ ʌȜȘțIJȡȠȜȩȖȚȠ ȑȞĮȞ ʌȡĮȖȝĮIJȚțȩ ĮȡȚșȝȩ țĮȚ ȞĮ İțIJȣʌȫȞİȚ: Į) ȉȠ IJİIJȡȐȖȦȞȩ IJȠȣ. ȕ) ȉȘȞ IJİIJȡĮȖȦȞȚțȒ IJȠȣ ȡȓȗĮ. Ȗ) ȉȠȞ ĮȡȚșȝȩ ıIJȡȠȖȖȣȜȠʌȠȚȘȝȑȞȠ ıIJȠȞ ʌȜȘıȚȑıIJİȡȠ ĮțȑȡĮȚȠ. į) ȉȠȞ ĮȡȚșȝȩ ȤȦȡȓȢ IJĮ įİțĮįȚțȐ IJȠȣ ȥȘijȓĮ. DZıțȘıȘ 3.4 īȡȐȥIJİ ʌȡȩȖȡĮȝȝĮ, ex34.pas, IJȠ ȠʌȠȓȠ ȞĮ ȗȘIJȐ Įʌȩ IJȠȞ ȤȡȒıIJȘ ȞĮ İȚıȐȖİȚ ȑȞĮȞ ȤĮȡĮțIJȒȡĮ țĮȚ ıIJȘȞ ıȣȞȑȤİȚĮ ȞĮ İțIJȣʌȫȞİȚ IJȠȣȢ 5 ʌȡȠȘȖȠȪȝİȞȠȣȢ ȤĮȡĮțIJȒȡİȢ, IJȠȞ ȤĮȡĮțIJȒȡĮ ʌȠȣ İȚıȒȖĮȖİ Ƞ ȤȡȒıIJȘȢ țĮȚ IJȠȣȢ 5 İʌȩȝİȞȠȣȢ ȤĮȡĮțIJȒȡİȢ țĮșȫȢ İʌȓıȘȢ țĮȚ IJȠȣȢ țȦįȚțȠȪȢ ASCII ȠȚ ȠʌȠȓȠȚ ĮȞIJȚıIJȠȚȤȠȪȞ ıIJȠȣȢ ȤĮȡĮțIJȒȡİȢ ĮȣIJȠȪȢ Ȇ.Ȥ. ĮȞ Ƞ ȤȡȒıIJȘȢ İȚıȐȖİȚ IJȠȞ ȤĮȡĮțIJȒȡĮ 'F', IJȠ ʌȡȩȖȡĮȝȝĮ șĮ ʌȡȑʌİȚ ȞĮ İțIJȣʌȫıİȚ ıIJȘȞ ȠșȩȞȘ: A 65 B 66 C 67 D 68 E 69 F 70 G 71 H 72 I 73 J 74 K 75

ǹș. Ǽ. ȀȠȣIJıȠȞȚțȩȜĮȢ


22

ǹȈȀǾȈǾ 3

ȈǾȂǼǿȍȈǼǿȈ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________


23

ǹȈȀǾȈǾ 4 ǼȞIJȠȜȑȢ ǻȚĮțȜȐįȦıȘȢ 4.1 ǼȚıĮȖȦȖȒ ȅȚ İȞIJȠȜȑȢ IJȘȢ Pascal IJȚȢ ȠʌȠȓİȢ ȖȞȦȡȓıĮȝİ ȝȑȤȡȚ ıIJȚȖȝȒȢ, ȤȡȘıȚȝȠʌȠȚȠȪȞIJĮȚ ȖȚĮ İȓıȠįȠ / ȑȟȠįȠ įİįȠȝȑȞȦȞ țĮȚ ȣʌȠȜȠȖȚıȝȠȪȢ. ȅȚ İȞIJȠȜȑȢ ĮȣIJȑȢ İțIJİȜȠȪȞIJĮȚ įȚĮįȠȤȚțȐ Ș ȝȓĮ ȝİIJȐ IJȘȞ ȐȜȜȘ ʌȐȞIJȠIJİ ȝİ IJȘȞ ȓįȚĮ ıİȚȡȐ ʌȠȣ İȓȞĮȚ ȖȡĮȝȝȑȞİȢ. ȆȠȜȪ ıȣȤȞȐ ȣʌȐȡȤİȚ Ș ĮȞȐȖțȘ İțIJȑȜİıȘȢ įȚĮijȠȡİIJȚțȫȞ İȞIJȠȜȫȞ țĮȚ ȣʌȠȜȠȖȚıȝȫȞ, ĮȞȐȜȠȖĮ ȝİ IJĮ įİįȠȝȑȞĮ IJȠȣ ʌȡȠȕȜȒȝĮIJȠȢ. īȚĮ ʌĮȡȐįİȚȖȝĮ İȐȞ șȑȜȠȣȝİ ȞĮ ȖȡȐȥȠȣȝİ ȑȞĮ ʌȡȩȖȡĮȝȝĮ IJȠ ȠʌȠȓȠ İțIJȣʌȫȞİȚ IJȠ ȝİȖĮȜȪIJİȡȠ Įʌȩ įȪȠ ĮȡȚșȝȠȪȢ IJȠȣȢ ȠʌȠȓȠȣȢ İȚıȐȖİȚ Ƞ ȤȡȒıIJȘȢ, IJȩIJİ șĮ ʌȡȑʌİȚ IJȠ ʌȡȩȖȡĮȝȝĮ ȞĮ ĮʌȠijĮıȓıİȚ ʌȠȚȩȞ Įʌȩ IJȠȣȢ įȪȠ ĮȡȚșȝȠȪȢ șĮ ʌȡȑʌİȚ ȞĮ İțIJȣʌȫıİȚ. 4.2 Ǿ ǼȞIJȠȜȒ If .. Then .. Else īȚĮ IJȘȞ ȜȒȥȘ ȜȠȖȚțȫȞ ĮʌȠijȐıİȦȞ țĮȚ IJȘȞ įȚĮțȜȐįȦıȘ ıİ įȚĮijȠȡİIJȚțȐ ıȘȝİȓĮ IJȠȣ ʌȡȠȖȡȐȝȝĮIJȠȢ ȤȡȘıȚȝȠʌȠȚİȓIJĮȚ Ș İȞIJȠȜȒ If..Then..Else. Ǿ ıȪȞIJĮȟȘ IJȘȢ İȞIJȠȜȒȢ ĮȣIJȒȢ İȓȞĮȚ Ș ʌĮȡĮțȐIJȦ: If ȜȠȖȚțȒ_ȑțijȡĮıȘ Then İȞIJȠȜȒ1 Else İȞIJȠȜȒ2; ȩʌȠȣ İȞIJȠȜȒ1 İȓȞĮȚ İȞIJȠȜȒ Ș ȠʌȠȓĮ İțIJİȜİȓIJĮȚ ıIJȘȞ ʌİȡȓʌIJȦıȘ ʌȠȣ Ș ȜȠȖȚțȒ ȑțijȡĮıȘ İȓȞĮȚ ĮȜȘșȒȢ (True) țĮȚ İȞIJȠȜȒ2 Ș İȞIJȠȜȒ Ș ȠʌȠȓĮ İțIJİȜİȓIJĮȚ ıIJȘȞ ʌİȡȓʌIJȦıȘ ʌȠȣ Ș ȜȠȖȚțȒ ȑțijȡĮıȘ İȓȞĮȚ ȥİȣįȒȢ (False). ȉȠ IJȝȒȝĮ Else İȞIJȠȜȒ2 ıİ ʌİȡȓʌIJȦıȘ ʌȠȣ įİȞ ȤȡİȚȐȗİIJĮȚ ȝʌȠȡİȓ ȞĮ ʌĮȡĮȜȘijșİȓ. ȉȠ İȜȜȘȞȚțȩ İȡȦIJȘȝĮIJȚțȩ IJȠʌȠșİIJİȓIJĮȚ ıIJȠ IJȑȜȠȢ IJȘȢ İȞIJȠȜȒȢ If. ȆȡȚȞ Įʌȩ IJȠ Else, įİȞ IJȠʌȠșİIJİȓIJĮȚ ʌȠIJȑ İȜȜȘȞȚțȩ İȡȦIJȘȝĮIJȚțȩ (İȓȞĮȚ ıȣȞIJĮțIJȚțȩ ȜȐșȠȢ). īȚĮ IJȘȞ ıȪȞIJĮȟȘ ȜȠȖȚțȫȞ İțijȡȐıİȦȞ Ș Pascal įȚĮșȑIJİȚ IJȠȣȢ ʌĮȡĮțȐIJȦ IJİȜİıIJȑȢ ıȪȖțȡȚıȘȢ (ȜȑȖȠȞIJĮȚ İʌȓıȘȢ țĮȚ ıȣıȤİIJȚıIJȚțȠȓ IJİȜİıIJȑȢ) ȠȚ ȠʌȠȓȠȚ ȤȡȘıȚȝȠʌȠȚȠȪȞIJĮȚ ȖȚĮ IJȘȞ ıȪȖțȡȚıȘ ȝİIJĮȕȜȘIJȫȞ ıIJĮșİȡȫȞ țĮȚ ʌĮȡĮıIJȐıİȦȞ: = > < >= <= <>

ȓıȠ ȝİȖĮȜȪIJİȡȠ ȝȚțȡȩIJİȡȠ ȝİȖĮȜȪIJİȡȠ Ȓ ȓıȠ ȝȚțȡȩIJİȡȠ Ȓ ȓıȠ įȚȐijȠȡȠ

ȆĮȡĮįİȓȖȝĮIJĮ ȜȠȖȚțȫȞ İțijȡȐıİȦȞ İȓȞĮȚ IJĮ ʌĮȡĮțȐIJȦ: a>b c <= 3.89 a <> b īȚĮ IJȘȞ ıȪȞIJĮȟȘ ʌȚȠ ʌȠȜȪʌȜȠțȦȞ ȜȠȖȚțȫȞ İțijȡȐıİȦȞ, ıİ ʌİȡȚʌIJȫıİȚȢ ıIJȚȢ ȠʌȠȓİȢ ȤȡİȚȐȗİIJĮȚ Ƞ ıȣȞįȣĮıȝȩȢ ʌİȡȚııȩIJİȡȦȞ țȡȚIJȘȡȓȦȞ (ʌ.Ȥ. a > 1 țĮȚ a < 10), Ș Pascal įȚĮșȑIJİȚ IJȠȣȢ ʌĮȡĮțȐIJȦ ȜȠȖȚțȠȪȢ IJİȜİıIJȑȢ: ȃOT

ȜȠȖȚțȩ ȅȋǿ (ȐȡȞȘıȘ)

ǹND

ȜȠȖȚțȩ KAI (ıȪȗİȣȟȘ)

ȅR

ȜȠȖȚțȩ Ǿ (įȚȐȗİȣȟȘ)

XOR

ĮʌȠțȜİȚıIJȚțȒ įȚȐȗİȣȟȘ

ȈIJȘȞ ıȪȞIJĮȟȘ ʌȠȜȪʌȜȠțȦȞ ȜȠȖȚțȫȞ İțijȡȐıİȦȞ ȝʌȠȡȠȪȞ ȞĮ ȤȡȘıȚȝȠʌȠȚȘșȠȪȞ ʌĮȡİȞșȑıİȚȢ ȩʌȦȢ ĮțȡȚȕȫȢ ȖȓȞİIJĮȚ țĮȚ ȝİ IJȚȢ ĮȡȚșȝȘIJȚțȑȢ ʌĮȡĮıIJȐıİȚȢ.


24

ǹȈȀǾȈǾ 4

ȆĮȡȐįİȚȖȝĮ: (a > 1) And (a < 10) ((a > b) And (a < c) And (b < c)) Or (b = 0) ȆĮȡȐįİȚȖȝĮ ȤȡȒıȘȢ IJȘȢ İȞIJȠȜȒȢ If .. Then .. Else İȓȞĮȚ IJȠ ʌĮȡĮțȐIJȦ ʌȡȩȖȡĮȝȝĮ IJȠ ȠʌȠȓȠ ȗȘIJȐ Įʌȩ IJȠȞ ȤȡȒıIJȘ įȪȠ ĮȡȚșȝȠȪȢ țĮȚ ıIJȘȞ ıȣȞȑȤİȚĮ İțIJȣʌȫȞİȚ IJȠȞ ȝİȖĮȜȪIJİȡȠ Įʌȩ IJȠȣȢ įȪȠ: Program Comparison; Var x,y : Real; Begin Write('ǻȫıİ įȪȠ ĮȡȚșȝȠȪȢ ') Readln(x,y); If x>y Then Writeln('ȂİȖĮȜȪIJİȡȠȢ İȓȞĮȚ Ƞ ĮȡȚșȝȩȢ ', x) Else Writeln('ȂİȖĮȜȪIJİȡȠȢ İȓȞĮȚ Ƞ ĮȡȚșȝȩȢ ', y); End. ȈȣȤȞȐ ĮʌĮȚIJİȓIJĮȚ ıIJȠ IJȝȒȝĮ Then Ȓ/țĮȚ ıIJȠ IJȝȒȝĮ Else, ȞĮ İțIJİȜİıIJȠȪȞ ʌİȡȚııȩIJİȡİȢ Įʌȩ ȝȓĮ İȞIJȠȜȑȢ. ȈIJȘȞ ʌİȡȓʌIJȦıȘ ĮȣIJȒ șĮ ʌȡȑʌİȚ ȠȚ İȞIJȠȜȑȢ ĮȣIJȑȢ ȞĮ ȠȝĮįȠʌȠȚȘșȠȪȞ ȑIJıȚ ȫıIJİ ȞĮ ĮʌȠIJİȜȑıȠȣȞ ȝȓĮ ıȪȞșİIJȘ İȞIJȠȜȒ (compound statement), ȝİ IJȘȞ ȤȡȒıȘ IJȦȞ įİıȝİȣȝȑȞȦȞ ȜȑȟİȦȞ Begin țĮȚ End . ȆĮȡȐįİȚȖȝĮ: If ȜȠȖȚțȒ_ȑțijȡĮıȘ Then Begin İȞIJȠȜȒ1_1; İȞIJȠȜȒ1_2; ...... İȞIJȠȜȒ1_n; End Else Begin İȞIJȠȜȒ2_1; İȞIJȠȜȒ2_2; ...... İȞIJȠȜȒ2_n; End; ȆȡȠıȑȟIJİ IJĮ İȜȜȘȞȚțȐ İȡȦIJȘȝĮIJȚțȐ țĮIJȐ IJȘȞ ıȪȞIJĮȟȘ IJȘȢ İȞIJȠȜȒȢ If .. Then .. Else. ȈIJȠ IJȑȜȠȢ IJȠȣ IJȝȒȝĮIJȠȢ Then įİȞ ʌȡȑʌİȚ ȞĮ IJȠʌȠșİIJİȓIJĮȚ İȜȜȘȞȚțȩ İȡȦIJȘȝĮIJȚțȩ ȩIJĮȞ ĮțȠȜȠȣșİȓ Else, İȞȫ ȩIJĮȞ įİȞ ȣʌȐȡȤİȚ IJȠ IJȝȒȝĮ Else IJȩIJİ IJȠ İȜȜȘȞȚțȩ İȡȦIJȘȝĮIJȚțȩ ȤȡİȚȐȗİIJĮȚ ȖȚĮ ȞĮ įȘȜȫıİȚ IJȠ IJȑȜȠȢ IJȘȢ İȞIJȠȜȒȢ. ȈIJȠ IJȑȜȠȢ IJȠȣ IJȝȒȝĮIJȠȢ Else, IJȠ İȜȜȘȞȚțȩ İȡȦIJȘȝĮIJȚțȩ İȓȞĮȚ ĮʌĮȡĮȓIJȘIJȠ, ȖȚĮ ȞĮ įȘȜȫıİȚ IJȠ IJȑȜȠȢ IJȘȢ İȞIJȠȜȒȢ. Ǿ ȑȞșİıȘ İȞIJȠȜȒȢ If .. Then .. Else İȞIJȩȢ țȐʌȠȚĮȢ ȐȜȜȘȢ İȞIJȠȜȒȢ If .. Then .. Else, İȓȞĮȚ įȣȞĮIJȒ. ȈIJȘȞ ʌİȡȓʌIJȦıȘ ĮȣIJȒ, ȖȚĮ ȞĮ ȝȘȞ ȣʌȐȡȤİȚ ıȪȖȤȣıȘ ȩıȠȞ ĮijȠȡȐ IJȠ İȡȫIJȘȝĮ ıİ ʌȠȚȠ If ĮȞIJȚıIJȠȚȤİȓ IJȠ țȐșİ Else, ȑȞĮȢ ȖİȞȚțȩȢ țĮȞȩȞĮȢ İȓȞĮȚ ȩIJȚ: țȐșİ Else ĮȞIJȚıIJȠȚȤİȓ ȝİ IJȠ ĮȝȑıȦȢ ʌȡȠȘȖȠȪȝİȞȠ If IJȠ ȠʌȠȓȠ įİȞ ȑȤİȚ IJȠ įȚțȩ Else. ȆĮȡȐįİȚȖȝĮ: If x > 0 Then If x < 2000 Then Writeln('ȉȠ x İȓȞĮȚ ȝȚțȡȩȢ șİIJȚțȩȢ ĮȡȚșȝȩȢ') Else Writeln('ȉȠ x İȓȞĮȚ ȝİȖȐȜȠȢ șİIJȚțȩȢ ĮȡȚșȝȩȢ') Else Writeln('ȉȠ x İȓȞĮȚ ĮȡȞȘIJȚțȩȢ ĮȡȚșȝȩȢ');


ǼȞIJȠȜȑȢ ǻȚĮțȜȐįȦıȘȢ

25

4.3 ȅ ȉİȜİıIJȒȢ In Ȉİ ʌİȡȓʌIJȦıȘ ʌȠȣ ȤȡİȚȐȗİIJĮȚ ȞĮ ȖȓȞİȚ ȑȜİȖȤȠȢ İȐȞ țȐʌȠȚĮ IJȚȝȒ ĮȞȒțİȚ ıİ ȑȞĮ ıȪȞȠȜȠ IJĮțIJȚțȠȪ IJȪʌȠȣ IJȚȝȫȞ, IJȩIJİ ȤȡȘıȚȝȠʌȠȚİȓIJĮȚ Ƞ IJİȜİıIJȒȢ IN. ȆİȡȚııȩIJİȡĮ ȖȚĮ IJĮ ıȪȞȠȜĮ șĮ įȠȪȝİ ıIJȘȞ DZıțȘıȘ 8. ȆĮȡȐįİȚȖȝĮ: i In [1,3,5,7,9]

EȜȑȖȤİȚ İȐȞ Ƞ ĮțȑȡĮȚȠȢ i İȓȞĮȚ 1, 3 ,5, 7 Ȓ 9

ch In ['A', 'B', 'C']

ǼȜȑȖȤİȚ İȐȞ Ƞ ȤĮȡĮțIJȒȡĮȢ ch İȓȞĮȚ 'ǹ', 'Ǻ' Ȓ 'C'

ǼȐȞ ȠȚ IJȚȝȑȢ IJȠȣ ıȣȞȩȜȠȣ İȓȞĮȚ ıȣȞİȤȩȝİȞİȢ IJȩIJİ ȝʌȠȡȠȪȝİ ȞĮ ȤȡȘıȚȝȠʌȠȚȒıȠȣȝİ IJȘȞ ȑțijȡĮıȘ: ĮȡȤȚțȒ_IJȚȝȒ .. IJİȜȚțȒ_IJȚȝȒ ȆĮȡȐįİȚȖȝĮ: j In [1..99]

ǼȜȑȖȤİȚ İȐȞ Ƞ j ĮȞȒțİȚ ıIJȠ įȚȐıIJȘȝĮ Įʌȩ 1 .. 99

4.4 Ǿ ǼȞIJȠȜȒ Case Ǿ İȞIJȠȜȒ įȚĮțȜȐįȦıȘȢ If..Then..Else ȝĮȢ įȓȞİȚ įȪȠ İʌȚȜȠȖȑȢ įȚĮțȜȐįȦıȘȢ ĮȞĮȜȩȖȦȢ IJȘȢ IJȚȝȒȢ IJȘȢ ȜȠȖȚțȒȢ ȑțijȡĮıȘȢ. ȈȣȤȞȐ ȩȝȦȢ İȓȞĮȚ ĮʌĮȡĮȓIJȘIJȠ ȞĮ ȖȓȞȠȣȞ ʌȠȜȜĮʌȜȑȢ İʌȚȜȠȖȑȢ ĮȞĮȜȩȖȦȢ IJȘȢ IJȚȝȒȢ țȐʌȠȚĮȢ ȝİIJĮȕȜȘIJȒȢ Ȓ țȐʌȠȚĮȢ ʌĮȡȐıIJĮıȘȢ. ȈIJȚȢ ʌİȡȚʌIJȫıİȚȢ ĮȣIJȑȢ ȝʌȠȡȠȪȞ ȞĮ ȤȡȘıȚȝȠʌȠȚȘșȠȪȞ ʌȠȜȜĮʌȜȑȢ İȞIJȠȜȑȢ If .. Then .. Else, İȓIJİ ȑȞșİIJİȢ İȓIJİ ĮʌȜȑȢ, ȩȝȦȢ ʌȡȠIJȚȝȐIJĮȚ Ș İȞIJȠȜȒ ʌȠȜȜĮʌȜȒȢ İʌȚȜȠȖȒȢ Case. Ǿ ıȪȞIJĮȟȘ IJȘȢ İȞIJȠȜȒȢ ĮȣIJȒȢ İȓȞĮȚ Ș ʌĮȡĮțȐIJȦ: Case ʌĮȡȐıIJĮıȘ of ȜȓıIJĮ IJȚȝȫȞ1 : İȞIJȠȜȒ1; ȜȓıIJĮ IJȚȝȫȞ2 : İȞIJȠȜȒ2; .. .. ȜȓıIJĮ IJȚȝȫȞn : İȞIJȠȜȒn Else İȞIJȠȜȒm End; ǹȡȤȚțȐ ȣʌȠȜȠȖȓȗİIJĮȚ Ș IJȚȝȒ IJȘȢ ʌĮȡȐıIJĮıȘȢ, ĮȞ ĮȣIJȒ Ș IJȚȝȒ ȕȡİșİȓ ıIJȘȞ ȜȓıIJĮ IJȚȝȫȞk IJȩIJİ İțIJİȜİȓIJĮȚ Ș İȞIJȠȜȒk. ǹȞ Ș IJȚȝȒ IJȘȢ ʌĮȡȐıIJĮıȘȢ įİȞ ȕȡİșİȓ ıİ țĮȝȓĮ ȜȓıIJĮ IJȚȝȫȞ, IJȩIJİ İțIJİȜİȓIJĮȚ Ș İȞIJȠȜȒm, İijȩıȠȞ ȣʌȐȡȤİȚ IJȠ IJȝȒȝĮ Else. ȆĮȡĮįİȓȖȝĮIJĮ: To ʌĮȡĮțȐIJȦ ʌȡȩȖȡĮȝȝĮ ȗȘIJȐ Įʌȩ IJȠȞ ȤȡȒıIJȘ ȞĮ İȚıȐȖİȚ ȑȞĮȞ șİIJȚțȩ ĮțȑȡĮȚȠ ȝȚțȡȩIJİȡȠ IJȠȣ ʌȑȞIJİ țĮȚ ıIJȘȞ ıȣȞȑȤİȚĮ IJȣʌȫȞİȚ IJȠȞ ĮȡȚșȝȩ ȠȜȠȖȡȐijȦȢ ıIJȘȞ ȠșȩȞȘ, İȞȫ ĮȞ Ƞ ĮȡȚșȝȩȢ İȓȞĮȚ ȑȟȦ Įʌȩ IJȠ įȚȐıIJȘȝĮ 1..5, IJȣʌȫȞİȚ țĮIJȐȜȜȘȜȠ ȝȒȞȣȝĮ. Program Multichoice; Var i: Integer; Begin Write('ǻȫıİ ȑȞĮȞ șİIJȚțȩ ĮțȑȡĮȚȠ ȝȚțȡȩIJİȡȠ IJȠȣ 5 '); Readln(i); Case i of 0: Writeln('ȂȘįȑȞ'); 1: Writeln('ǼȞĮ'); 2: Writeln('ǻȪȠ'); 3: Writeln('ȉȡȓĮ'); 4: Writeln('ȉȑııİȡĮ'); 5: Writeln('ȆȑȞIJİ') Else Writeln('ǹȡȚșȝȩȢ İțIJȩȢ ȠȡȓȦȞ'); End; End.

ǹș. Ǽ. ȀȠȣIJıȠȞȚțȩȜĮȢ


26

ǹȈȀǾȈǾ 4

ȈIJȠ ʌĮȡĮțȐIJȦ IJȝȒȝĮ ʌȡȠȖȡȐȝȝĮIJȠȢ, IJȣʌȫȞȠȣȝİ IJȠȞ ȤĮȡĮțIJȘȡȚıȝȩ ijȠȓIJȘıȘȢ İȞȩȢ ıʌȠȣįĮıIJȒ, ĮȞȐȜȠȖĮ ȝİ IJȠȞ ȕĮșȝȩ IJȠȣ: Case i of 0,1,2,3 : Writeln('ȀĮțȫȢ'); 4 : Writeln('ǹȞİʌĮȡțȫȢ'); 5,6 : Writeln('ȀĮȜȫȢ'); 7,8 : Writeln('ȁȓĮȞ țĮȜȫȢ'); 9,10 : Writeln('ǹȡȚıIJĮ'); End; ȈIJȘȞ ʌİȡȓʌIJȦıȘ IJĮțIJȚțȫȞ IJȪʌȦȞ ȝİIJĮȕȜȘIJȫȞ ȩʌȠȣ ȠȚ IJȚȝȑȢ ȝȚĮȢ İʌȚȜȠȖȒȢ ȝʌȠȡȠȪȞ ȞĮ ʌĮȡĮıIJĮșȠȪȞ Įʌȩ ȑȞĮ țȜİȚıIJȩ įȚȐıIJȘȝĮ IJȚȝȫȞ (ʌȐȞȦ țĮȚ țȐIJȦ ȩȡȚȠ), IJȩIJİ ȝʌȠȡȠȪȝİ ȞĮ ȤȡȘıȚȝȠʌȠȚȒıȠȣȝİ: ĮȡȤȚțȒ_IJȚȝȒ .. IJİȜȚțȒ_IJȚȝȒ, ĮȞIJȓ ȞĮ ʌĮȡĮșȑıȠȣȝİ ȩȜİȢ IJȚȢ įȣȞĮIJȑȢ IJȚȝȑȢ IJȠȣ įȚĮıIJȒȝĮIJȠȢ ĮȣIJȠȪ. DzIJıȚ IJȠ ʌȡȠȘȖȠȪȝİȞȠ ʌĮȡȐįİȚȖȝĮ ȝʌȠȡİȓ ȞĮ ȖȓȞİȚ: Case i of 0..3 : Writeln('ȀĮțȫȢ'); 4 : Writeln('ǹȞİʌĮȡțȫȢ'); 5,6 : Writeln('ȀĮȜȫȢ'); 7,8 : Writeln('ȁȓĮȞ țĮȜȫȢ'); 9,10 : Writeln('ǹȡȚıIJĮ'); End; Ǿ ȝİIJĮȕȜȘIJȒ (Ȓ IJȠ ĮʌȠIJȑȜİıȝĮ IJȘȢ ʌĮȡȐıIJĮıȘȢ) Ș ȠʌȠȓĮ ȤȡȘıȚȝȠʌȠȚİȓIJĮȚ ȖȚĮ IJȘȞ İȞIJȠȜȒ Case ʌȡȑʌİȚ ȞĮ ĮȞȒțİȚ ıIJȠȣȢ IJĮțIJȚțȠȪȢ IJȪʌȠȣȢ įİįȠȝȑȞȦȞ, įȘȜĮįȒ ȝʌȠȡİȓ ȞĮ İȓȞĮȚ ĮțȑȡĮȚȠȢ, ȜȠȖȚțȩȢ Ȓ ȤĮȡĮțIJȒȡĮȢ ĮȜȜȐ įİȞ ȝʌȠȡİȓ ȞĮ İȓȞĮȚ ʌȡĮȖȝĮIJȚțȩȢ. ǼȐȞ ȤȡİȚȐȗİIJĮȚ, ıİ țȐʌȠȚĮ İʌȚȜȠȖȒ ȝʌȠȡȠȪȞ ȞĮ ȠȝĮįȠʌȠȚȘșȠȪȞ ʌİȡȚııȩIJİȡİȢ Įʌȩ ȝȓĮ İȞIJȠȜȑȢ ȝİ IJȘȞ ȤȡȒıȘ IJȦȞ įİıȝİȣȝȑȞȦȞ ȜȑȟİȦȞ Begin țĮȚ End (ȩʌȦȢ țĮȚ ıIJȘȞ İȞIJȠȜȒ If..Then..Else). 4.5 ǹıțȒıİȚȢ DZıțȘıȘ 4.1 īȡȐȥIJİ ʌȡȩȖȡĮȝȝĮ, ex41.pas, IJȠ ȠʌȠȓȠ ȞĮ ȗȘIJȐ Įʌȩ IJȠȞ ȤȡȒıIJȘ ȞĮ İȚıȐȖİȚ ȑȞĮȞ șİIJȚțȩ ĮțȑȡĮȚȠ ȝȚțȡȩIJİȡȠ IJȠȣ 10000 țĮȚ ıIJȘȞ ıȣȞȑȤİȚĮ ȞĮ İțIJȣʌȫȞİȚ ĮȞ Ƞ ĮȡȚșȝȩȢ İȓȞĮȚ ȝȠȞȠȥȒijȚȠȢ, įȚȥȒijȚȠȢ, IJȡȚȥȒijȚȠȢ Ȓ IJİIJȡĮȥȒijȚȠȢ DZıțȘıȘ 4.2 īȡȐȥIJİ ʌȡȩȖȡĮȝȝĮ, ex42.pas, IJȠ ȠʌȠȓȠ ȞĮ ȗȘIJȐ Įʌȩ IJȠȞ ȤȡȒıIJȘ ȞĮ İȚıȐȖİȚ IJȠ ıȣȞȠȜȚțȩ İȚıȩįȘȝĮ IJȠȣ țĮȚ ıIJȘȞ ıȣȞȑȤİȚĮ ȣʌȠȜȠȖȓȗİȚ țĮȚ ȞĮ İțIJȣʌȫȞİȚ IJȠ ijȩȡȠ IJȠȞ ȠʌȠȓȠ șĮ ʌȡȑʌİȚ ȞĮ ʌȜȘȡȫıİȚ. ǹȞȐȜȠȖĮ ȝİ IJȠ İȚıȩįȘȝĮ, IJȠ ʌȠıȠıIJȩ IJȠȣ ijȩȡȠȣ İʌȓ IJȠȣ İȚıȠįȒȝĮIJȠȢ IJȠ ȠʌȠȓȠ șĮ ʌȜȘȡȫıİȚ Ƞ ijȠȡȠȜȠȖȠȪȝİȞȠȢ İȓȞĮȚ: ǼȚıȩįȘȝĮ ȆȠıȠıIJȩ ĭȩȡȠȣ <= 500000 0% > 500000 țĮȚ <= 2500000 5% > 2500000 țĮȚ < =4000000 15% > 4000000 țĮȚ < =7000000 25% > 7000000 40% ȃĮ ȜȐȕİIJİ ȣʌȩȥȘ ıĮȢ ȩIJȚ Ƞ ijȩȡȠȢ ʌȡȑʌİȚ ȞĮ ȣʌȠȜȠȖȓȗİIJĮȚ țȜȚȝĮțȦIJȐ. ǻȘȜĮįȒ ȖȚĮ İȚıȩįȘȝĮ 4500000 įȡȤ, ȠȚ ʌȡȫIJİȢ 500000 įȡȤ İȓȞĮȚ ĮijȠȡȠȜȩȖȘIJİȢ, ȠȚ İʌȩȝİȞİȢ 2000000 įȡȤ ijȠȡȠȜȠȖȠȪȞIJĮȚ ȝİ 5%, ȠȚ İʌȩȝİȞİȢ 1500000 įȡȤ ȝİ 15% țĮȚ IJȑȜȠȢ ȠȚ


ǼȞIJȠȜȑȢ ǻȚĮțȜȐįȦıȘȢ

27

ȣʌȩȜȠȚʌİȢ 500000 įȡȤ ȝİ 25%. DzIJıȚ Ƞ ıȣȞȠȜȚțȩȢ ijȩȡȠȢ ȖȚĮ IJĮ 4500000 İȓȞĮȚ 450000 įȡȤ. DZıțȘıȘ 4.3 īȚĮ ȞĮ ȣʌȐȡȤİȚ IJȡȓȖȦȞȠ ȝİ ʌȜİȣȡȑȢ a, b, c ʌȡȑʌİȚ ȞĮ ȚıȤȪİȚ: a<b+c țĮȚ b<a+c țĮȚ c<a+b. īȡȐȥIJİ ʌȡȩȖȡĮȝȝĮ, ex43.pas, ʌȠȣ ȞĮ įȚĮȕȐȗİȚ Įʌȩ IJȠ ʌȜȘțIJȡȠȜȩȖȚȠ IJĮ a, b, c țĮȚ ȞĮ IJȣʌȫȞİȚ IJȠ İȝȕĮįȩȞ IJȠȣ IJȡȚȖȫȞȠȣ ȝİ ʌȜİȣȡȑȢ a, b, c ĮȞ ȣʌȐȡȤİȚ. ȉȠ İȝȕĮįȩȞ įȓȞİIJĮȚ Įʌȩ IJȠȞ ʌĮȡĮțȐIJȦ IJȪʌȠ (IJȪʌȠȢ IJȠȣ dzȡȦȞĮ):

E

s (s  a)(s  b)(s  c)

ȩʌȠȣ

2s

a  b  c

DZıțȘıȘ 4.4 īȡȐȥIJİ ȑȞĮ ʌȡȩȖȡĮȝȝĮ, ex44.pas, ʌȠȣ ȞĮ ȣʌȠȜȠȖȓȗİȚ IJȚȢ ȡȓȗİȢ IJȘȢ įİȣIJİȡȠȕȐșȝȚĮȢ İȟȓıȦıȘȢ ax2+bx+c=0. ȉȠ įȚȐȖȡĮȝȝĮ ȡȠȒȢ IJȘȢ ȜȪıȘȢ įȓȞİIJĮȚ ʌĮȡĮțȐIJȦ: ǹȇȋǾ

ǻȚȐȕĮıİ a,b,c

ȃǹǿ ȅȋǿ

a=0

ȊʌȠȜȩȖȚıİ 2 d=b -4ac

d>=0

ȃǹǿ

ȉȪʌȦıİ 'ǻİȞ ȣʌȐȡȤȠȣȞ ʌȡĮȖȝĮIJȚțȑȢ ȡȓȗİȢ'

ȃǹǿ ȅȋǿ

b=0

ȅȋǿ

ȊʌȠȜȩȖȚıİ x1=-c/b

ȉȪʌȦıİ x1

ȊʌȠȜȩȖȚıİ x1,2=(-b±—(d))/(2a)

ȃǹǿ ȅȋǿ

c=0

ȉȪʌȦıİ 'ǹįȪȞĮIJȘ'

ȉȪʌȦıİ x1,x2

ȃǹǿ ȉȪʌȦıİ 'ǹȩȡȚıIJȘ'

ȉǼȁȅȈ

ȈǾȂǼǿȍȈǼǿȈ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________

ǹș. Ǽ. ȀȠȣIJıȠȞȚțȩȜĮȢ


28

ǹȈȀǾȈǾ 4

_____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________


29

ǹȈȀǾȈǾ 5 ǼȞIJȠȜȑȢ ǼʌĮȞȐȜȘȥȘȢ 5.1 ǼȚıĮȖȦȖȒ ȈȣȤȞȐ ıIJȠȞ ʌȡȠȖȡĮȝȝĮIJȚıȝȩ ʌĮȡȠȣıȚȐȗİIJĮȚ Ș ĮȞȐȖțȘ ȞĮ İțIJİȜİıșȠȪȞ ʌȠȜȜȑȢ ijȠȡȑȢ ȠȚ ȓįȚİȢ İȞIJȠȜȑȢ, Ȓ IJĮ ȓįȚĮ țȠȝȝȐIJȚĮ IJȠȣ ʌȡȠȖȡȐȝȝĮIJȠȢ. ĭȣıȚțȐ ĮȣIJȩ ʌȠȣ ȝĮȢ İȞįȚĮijȑȡİȚ İȓȞĮȚ ȞĮ ȝĮȢ įȓȞİIJĮȚ Ș įȣȞĮIJȩIJȘIJĮ ȞĮ ȖȡȐȥȠȣȝİ IJȚȢ İȞIJȠȜȑȢ ȝȓĮ ijȠȡȐ țĮȚ ȞĮ ȝʌȠȡȠȪȝİ ȞĮ IJȚȢ İțIJİȜȠȪȝİ ʌȠȜȜȑȢ ijȠȡȑȢ. ǹȣIJȩ ȠįȒȖȘıİ ıIJȘ įȘȝȚȠȣȡȖȓĮ İȞIJȠȜȫȞ İʌĮȞȐȜȘȥȘȢ. ȈIJȚȢ İȞIJȠȜȑȢ İʌĮȞȐȜȘȥȘȢ, ȝȓĮ İȞȩIJȘIJĮ İȞIJȠȜȫȞ ʌȠȣ ĮʌȠIJİȜȠȪȞ IJȠ ıȫȝĮ IJȘȢ İʌĮȞȐȜȘȥȘȢ, İțIJİȜİȓIJĮȚ IJȩıİȢ ijȠȡȑȢ ȩıİȢ ȤȡİȚȐȗİIJĮȚ ȖȚĮ ȞĮ ȚțĮȞȠʌȠȚȘșİȓ țȐʌȠȚȠ țȡȚIJȒȡȚȠ. Ǿ Pascal įȚĮșȑIJİȚ IJȡȓĮ İȓįȘ İȞIJȠȜȫȞ İʌĮȞȐȜȘȥȘȢ IJĮ ȠʌȠȓĮ ȤȡȘıȚȝȠʌȠȚȠȪȞIJĮȚ ĮȞȐȜȠȖĮ ȝİ IJȘȞ ʌİȡȓʌIJȦıȘ. 5.2 Ǿ ǼȞIJȠȜȒ While Ǿ İȞIJȠȜȒ While ȤȡȘıȚȝȠʌȠȚİȓIJĮȚ ȩIJĮȞ įİȞ İȓȞĮȚ ȖȞȦıIJȩȢ İț IJȦȞ ʌȡȠIJȑȡȦȞ Ƞ ĮȡȚșȝȩȢ IJȦȞ İʌĮȞĮȜȒȥİȦȞ ȠȚ ȠʌȠȓİȢ șĮ ʌȡȑʌİȚ ȞĮ ȖȓȞȠȣȞ. īȚĮ ʌĮȡȐįİȚȖȝĮ İȐȞ șȑȜĮȝİ ȞĮ ȖȡȐȥȠȣȝİ ȑȞĮ ʌȡȩȖȡĮȝȝĮ IJȠ ȠʌȠȓȠ İțIJȣʌȫȞİȚ ȑȞĮ ȝȒȞȣȝĮ ıIJȘȞ ȠșȩȞȘ țĮȚ ıIJȘȞ ıȣȞȑȤİȚĮ ȗȘIJȐ Įʌȩ IJȠȞ ȤȡȒıIJȘ ȞĮ ʌȜȘțIJȡȠȜȠȖȒıİȚ 'ȃǹǿ' İȐȞ șȑȜİȚ ȞĮ ȖȓȞİȚ İʌĮȞİțIJȪʌȦıȘ IJȠȣ ȝȘȞȪȝĮIJȠȢ țĮȚ 'OXI' İȐȞ șȑȜİȚ ȞĮ IJİȜİȚȫıİȚ IJȠ ʌȡȩȖȡĮȝȝĮ, IJȩIJİ șĮ ȤȡİȚĮıIJİȓ ȞĮ ȤȡȘıȚȝȠʌȠȚȒıȠȣȝİ IJȘȞ İȞIJȠȜȒ While. Ǿ İȞIJȠȜȒ While ıȣȞIJȐııİIJĮȚ ȦȢ İȟȒȢ: While ȜȠȖȚțȒ_ȑțijȡĮıȘ do İȞIJȠȜȒ; ǹȡȤȚțȐ İȟİIJȐȗİIJĮȚ Ș ȜȠȖȚțȒ_ȑțijȡĮıȘ țĮȚ ĮȞ İȓȞĮȚ ĮȜȘșȒȢ (True), İțIJİȜİȓIJĮȚ Ș İȞIJȠȜȒ ȝİIJȐ IJȠ do țĮȚ İȟİIJȐȗİIJĮȚ ȟĮȞȐ Ș ȜȠȖȚțȒ ȑțijȡĮıȘ. ȅ ȕȡȩȤȠȢ ĮȣIJȩȢ ıȣȞİȤȓȗİIJĮȚ ȝȑȤȡȚ Ș ȜȠȖȚțȒ ȑțijȡĮıȘ ȞĮ ȖȓȞİȚ ȥİȣįȒȢ (False), ȠʌȩIJİ Ș İʌĮȞȐȜȘȥȘ ıIJĮȝĮIJȐİȚ țĮȚ İțIJİȜİȓIJĮȚ Ș İʌȩȝİȞȘ İȞIJȠȜȒ. ǼȐȞ İʌȚșȣȝȠȪȝİ ȞĮ İʌĮȞĮȜȐȕȠȣȝİ ȝİ IJȘȞ İȞIJȠȜȒ While ʌİȡȚııȩIJİȡİȢ Įʌȩ ȝȓĮ İȞIJȠȜȑȢ, IJȩIJİ șĮ ʌȡȑʌİȚ ȞĮ ȠȝĮįȠʌȠȚȒıȠȣȝİ IJȚȢ İȞIJȠȜȑȢ ĮȣIJȑȢ țȐȞȠȞIJȐȢ IJȚȢ ȝȚĮ ıȪȞșİIJȘ İȞIJȠȜȒ, ʌİȡȚțȜİȓȠȞIJȐȢ IJȚȢ ȝİIJĮȟȪ Begin țĮȚ End. ȆĮȡȐįİȚȖȝĮ: Program ǹskUser; Var answer : String[3]; Begin answer := 'ȃǹǿ' ; While answer = 'NAI' do Begin Writeln('ȀĮȜȘȝȑȡĮ'); Write('ȃĮ ıȣȞİȤȓıȦ; ȃǹǿ/ȅȋǿ '); Readln(answer); End; End. Ǿ ȜȠȖȚțȒ ȑțijȡĮıȘ Ș ȠʌȠȓĮ İȟİIJȐȗİIJĮȚ ıIJȠ ʌĮȡĮʌȐȞȦ ʌĮȡȐįİȚȖȝĮ İȓȞĮȚ țĮIJȐ ʌȩıȠ Ƞ ȤȡȒıIJȘȢ ĮʌȐȞIJȘıİ 'ȃǹǿ' ıIJȘȞ İȡȫIJȘıȘ 'ȃĮ ıȣȞİȤȓıȦ; ȃǹǿ/ȅȋǿ'. īȚĮ IJȘ ĮʌȠșȒțİȣıȘ IJȘȢ ĮʌȐȞIJȘıȘȢ IJȠȣ ȤȡȒıIJȘ ȤȡȘıȚȝȠʌȠȚȠȪȝİ IJȘȞ ȝİIJĮȕȜȘIJȒ answer. ǻȓȞȠȣȝİ ĮȡȤȚțȐ IJȘȞ IJȚȝȒ 'ȃǹǿ' ıIJȘȞ ȝİIJĮȕȜȘIJȒ answer ȫıIJİ IJȘȞ ʌȡȫIJȘ ijȠȡȐ ʌȠȣ șĮ ȖȓȞİȚ Ƞ ȑȜİȖȤȠȢ, Ș IJȚȝȒ IJȘȢ ȜȠȖȚțȒȢ ȑțijȡĮıȘȢ ȞĮ İȓȞĮȚ ĮȜȘșȒȢ. ĬĮ ʌȡȑʌİȚ ȞĮ įȓȞİIJĮȚ ȚįȚĮȓIJİȡȘ ʌȡȠıȠȤȒ ıIJȘȞ IJȚȝȒ IJȘȢ ȜȠȖȚțȒȢ ȑțijȡĮıȘȢ. ȈIJȠ ʌĮȡĮʌȐȞȦ ʌĮȡȐįİȚȖȝĮ İȐȞ įİȞ įȓȞĮȝİ ĮȡȤȚțȒ IJȚȝȒ ıIJȘȞ ȝİIJĮȕȜȘIJȒ answer, IJȩIJİ ĮȣIJȒ șĮ İȓȤİ ȝȓĮ IJȣȤĮȓĮ ĮȡȤȚțȒ IJȚȝȒ ʌȠȣ țĮIJȐ ʌȐıĮ ʌȚșĮȞȩIJȘIJĮ įİȞ șĮ ȒIJĮȞ 'ȃǹǿ' țĮȚ ȑIJıȚ


30

ǹȈȀǾȈǾ 5

įİȞ șĮ ȖȚȞȩIJĮȞ țĮȝȓĮ İʌĮȞȐȜȘȥȘ. ĬĮ ʌȡȑʌİȚ İʌȓıȘȢ ȞĮ ʌȡȠȕȜȑʌȠȣȝİ ʌȐȞIJĮ ȫıIJİ Ș ȜȠȖȚțȒ ȑțijȡĮıȘ ȞĮ ȖȓȞİȚ țȐʌȠIJİ ȥİȣįȒȢ ȫıIJİ ȞĮ IJİȜİȚȫıȠȣȞ ȠȚ İʌĮȞĮȜȒȥİȚȢ. ǼȐȞ ıIJȠ ʌĮȡĮʌȐȞȦ ʌȡȩȖȡĮȝȝĮ ʌĮȡĮȜİȓʌĮȝİ IJȘȞ ȖȡĮȝȝȒ: Readln(answer); Ș ȠʌȠȓĮ įȚĮȕȐȗİȚ IJȘȞ ĮʌȐȞIJȘıȘ IJȠȣ ȤȡȒıIJȘ, IJȩIJİ Ș ȝİIJĮȕȜȘIJȒ answer șĮ İȓȤİ ʌȐȞIJĮ IJȘȞ IJȚȝȒ 'ȃǹǿ', ȝİ ıȣȞȑʌİȚĮ Ș ȜȠȖȚțȒ ȑțijȡĮıȘ ȞĮ İȓȞĮȚ ʌȐȞIJĮ ĮȜȘșȒȢ țĮȚ ȠȚ İʌĮȞĮȜȒȥİȚȢ ȞĮ ıȣȞİȤȓȗȠȞIJĮȚ įȚĮȡțȫȢ. ǼȐȞ țĮIJȐ ȜȐșȠȢ ȕȡİșİȓIJİ ıİ ȝȓĮ IJȑIJȠȚĮ ʌİȡȓʌIJȦıȘ, IJȩIJİ ȝʌȠȡİȓIJİ ȞĮ įȚĮțȩȥİIJİ IJȘȞ İțIJȑȜİıȘ IJȠȣ ʌȡȠȖȡȐȝȝĮIJȠȢ ʌĮIJȫȞIJĮȢ IJȠ ıȣȞįȣĮıȝȩ ʌȜȒțIJȡȦȞ Ctrl-Break. Ȃİ IJȘȞ İȞIJȠȜȒ While įİȞ ȤȡȘıȚȝȠʌȠȚİȓIJĮȚ ȝİIJȡȘIJȒȢ İʌĮȞĮȜȒȥİȦȞ. ǼȐȞ ȩȝȦȢ țȐʌȠȚȠȢ IJȠ İʌȚșȣȝİȓ, ȝʌȠȡİȓ ȞĮ ȤȡȘıȚȝȠʌȠȚȒıİȚ țȐʌȠȚĮ ȝİIJĮȕȜȘIJȒ ıIJȘȞ ȠʌȠȓĮ ĮȡȤȚțȐ șĮ įȫıİȚ țȐʌȠȚĮ IJȚȝȒ țĮȚ ıIJȘȞ ıȣȞȑȤİȚĮ șĮ IJȘȞ ĮȣȟȐȞİȚ Ȓ șĮ IJȘȞ ȝİȚȫȞİȚ ıİ țȐșİ țȪțȜȠ İʌĮȞȐȜȘȥȘȢ. 5.3 Ǿ ǼȞIJȠȜȒ Repeat Ǿ İȞIJȠȜȒ ĮȣIJȒ İȓȞĮȚ ʌĮȡȩȝȠȚĮ ȝİ IJȘȞ İȞIJȠȜȒ While. ǻȚĮijȑȡİȚ ȦȢ ʌȡȠȢ IJȠ ʌȩIJİ İȟİIJȐȗİIJĮȚ Ș ȜȠȖȚțȒ ȑțijȡĮıȘ. Ǿ İȞIJȠȜȒ While İȟİIJȐȗİȚ IJȘȞ ȜȠȖȚțȒ ȑțijȡĮıȘ ıIJȘȞ ĮȡȤȒ țȐʌȠȚĮȢ İʌĮȞȐȜȘȥȘȢ İȞȫ Ș İȞIJȠȜȒ Repeat IJȘȞ İȟİIJȐȗİȚ ıIJȠ IJȑȜȠȢ țȐșİ İʌĮȞȐȜȘȥȘȢ. H ıȪȞIJĮȟȘ IJȘȢ İȞIJȠȜȒȢ Repeat İȓȞĮȚ: Repeat İȞIJȠȜȒ until ȜȠȖȚțȒ_ȑțijȡĮıȘ; ǼʌİȚįȒ ĮțȡȚȕȫȢ Ș İȞIJȠȜȒ Repeat İȟİIJȐȗİȚ IJȘȞ ȜȠȖȚțȒ ȑțijȡĮıȘ ıIJȠ IJȑȜȠȢ IJȘȢ İʌĮȞȐȜȘȥȘȢ, Ș İȞIJȠȜȒ İțIJİȜİȓIJĮȚ IJȠȣȜȐȤȚıIJȠȞ ȝȓĮ ijȠȡȐ. ȂȚĮ ȐȜȜȘ įȚĮijȠȡȐ IJȘȢ Repeat Įʌȩ IJȘȞ While İȓȞĮȚ ȩIJȚ ıIJȘȞ Repeat Ș İʌĮȞȐȜȘȥȘ ıȣȞİȤȓȗİIJĮȚ ȩıȠ Ș ȜȠȖȚțȒ ȑțijȡĮıȘ İȓȞĮȚ ȥİȣįȒȢ, İȞȫ ıIJȘȞ While ȩıȠ İȓȞĮȚ ĮȜȘșȒȢ EȐȞ șȑȜȠȣȝİ ȞĮ İʌĮȞĮȜȐȕȠȣȝİ ʌİȡȚııȩIJİȡİȢ Įʌȩ ȝȓĮ İȞIJȠȜȑȢ ȝʌȠȡȠȪȝİ ȞĮ IJȚȢ ʌĮȡİȝȕȐȜȜȠȣȝİ ȝİIJĮȟȪ IJȦȞ įİıȝİȣȝȑȞȦȞ ȜȑȟİȦȞ Repeat țĮȚ until ȤȦȡȓȢ ȞĮ ȤȡȘıȚȝȠʌȠȚȒıȠȣȝİ IJȚȢ ȜȑȟİȚȢ Begin țĮȚ End. ȉȠ ʌȡȠȘȖȠȪȝİȞȠ ʌĮȡȐįİȚȖȝĮ IJȘȢ İȞIJȠȜȒȢ While ȖȓȞİIJĮȚ ȝİ IJȘȞ ȤȡȒıȘ IJȘȢ İȞIJȠȜȒȢ Repeat: Program AskUser1; Var answer : String[3]; Begin Repeat Writeln('ȀĮȜȘȝȑȡĮ'); Write('ȃĮ ıȣȞİȤȓıȦ; ȃǹǿ/ȅȋǿ '); Readln(answer); until answer = 'ȅȋǿ'; End. 5.4 Ǿ ǼȞIJȠȜȒ For ǵIJĮȞ Ƞ ĮȡȚșȝȩȢ İʌĮȞĮȜȒȥİȦȞ İȓȞĮȚ ȖȞȦıIJȩȢ İț IJȦȞ ʌȡȠIJȑȡȦȞ, IJȩIJİ ȝʌȠȡİȓ ȞĮ ȤȡȘıȚȝȠʌȠȚȘșİȓ Ș İȞIJȠȜȒ İʌĮȞȐȜȘȥȘȢ For. Ǿ ıȪȞIJĮȟȘ IJȘȢ İȞIJȠȜȒȢ For İȓȞĮȚ: For ȝİIJĮȕȜȘIJȒ := ĮȡȤȚțȒ_IJȚȝȒ to IJİȜȚțȒ_IJȚȝȒ do İȞIJȠȜȒ; ȩʌȠȣ ȝİIJĮȕȜȘIJȒ İȓȞĮȚ ıȣȞȒșȦȢ ȝȚĮ ĮțȑȡĮȚĮ ȝİIJĮȕȜȘIJȒ Ȓ țȐʌȠȚĮ ȐȜȜȘ IJĮțIJȚțȠȪ IJȪʌȠȣ ȝİIJĮȕȜȘIJȒ Ș ȠʌȠȓĮ ȤȡȘıȚȝȠʌȠȚİȓIJĮȚ ȦȢ ȝİIJȡȘIJȒȢ IJȦȞ İʌĮȞĮȜȒȥİȦȞ. Ǿ ȝİIJĮȕȜȘIJȒ ʌĮȓȡȞİȚ ȦȢ ĮȡȤȚțȒ IJȚȝȒ IJȘȞ ĮȡȤȚțȒ IJȚȝȒ ʌȠȣ ȠȡȓȗİIJĮȚ ȝİ IJȘȞ İȞIJȠȜȒ For țĮȚ ĮȣȟȐȞİIJĮȚ įȚĮįȠȤȚțȐ țĮIJȐ ȑȞĮ ȑȦȢ ȩIJȠȣ ijșȐıİȚ IJȘȞ IJİȜȚțȒ IJȚȝȒ. Ȉİ țȐșİ ĮȜȜĮȖȒ IJȘȢ IJȚȝȒȢ IJȘȢ ȝİIJĮȕȜȘIJȒȢ, İțIJİȜİȓIJĮȚ Ș İȞIJȠȜȒ Ș ȠʌȠȓĮ ĮțȠȜȠȣșİȓ ȝİIJȐ IJȘȞ ȜȑȟȘ do.


ǼȞIJȠȜȑȢ ǼʌĮȞȐȜȘȥȘȢ

31

īȚĮ ʌĮȡȐįİȚȖȝĮ IJȠ ʌĮȡĮțȐIJȦ ʌȡȩȖȡĮȝȝĮ İțIJȣʌȫȞİȚ ıIJȘȞ ȠșȩȞȘ IJȠ ȓįȚȠ ȝȒȞȣȝĮ 10 ijȠȡȑȢ: Program Loop; Var i:Integer; Begin For i := 1 to 10 do Writeln('ȀĮȜȘȝȑȡĮ'); End. ǼȐȞ ıIJȠ ʌȡȠȘȖȠȪȝİȞȠ ʌȡȩȖȡĮȝȝĮ șȑȜȠȣȝİ ȞĮ ȕȜȑʌȠȣȝİ IJĮȣIJȩȤȡȠȞĮ țĮȚ IJȚȢ ĮȜȜĮȖȑȢ IJȚȝȒȢ IJȘȢ ȝİIJĮȕȜȘIJȒȢ i , IJȩIJİ ĮȣIJȩ ȖȓȞİIJĮȚ: Program Loop; Var i:Integer; Begin For i := 1 to 10 do Writeln('i = ', i ,' ȀĮȜȘȝȑȡĮ'); End. ȉȠ ʌĮȡĮʌȐȞȦ ʌȡȩȖȡĮȝȝĮ ȝİIJȐ IJȘȞ İțIJȑȜİıȘ IJȠȣ İȝijĮȞȓȗİȚ ıIJȘȞ ȠșȩȞȘ IJĮ ʌĮȡĮțȐIJȦ ȝȘȞȪȝĮIJĮ: i = 1 ȀĮȜȘȝȑȡĮ i = 2 ȀĮȜȘȝȑȡĮ i = 3 ȀĮȜȘȝȑȡĮ i = 4 ȀĮȜȘȝȑȡĮ i = 5 ȀĮȜȘȝȑȡĮ i = 6 ȀĮȜȘȝȑȡĮ i = 7 ȀĮȜȘȝȑȡĮ i = 8 ȀĮȜȘȝȑȡĮ i = 9 ȀĮȜȘȝȑȡĮ i = 10 ȀĮȜȘȝȑȡĮ ǼȓȞĮȚ įȣȞĮIJȩȞ İʌȠȝȑȞȦȢ ȞĮ ȤȡȘıȚȝȠʌȠȚȘșİȓ Ƞ ȝİIJȡȘIJȒȢ IJȘȢ İʌĮȞȐȜȘȥȘȢ ȦȢ ȝȓĮ țĮȞȠȞȚțȒ ȝİIJĮȕȜȘIJȒ IJȩıȠ ȖȚĮ İțIJȪʌȦıȘ ıIJȘȞ ȠșȩȞȘ, ȩıȠ țĮȚ ȖȚĮ įȚȐijȠȡȠȣȢ ȣʌȠȜȠȖȚıȝȠȪȢ. ǵȝȦȢ įİȞ İʌȚIJȡȑʌİIJĮȚ ıİ țĮȝȓĮ ʌİȡȓʌIJȦıȘ ȞĮ ĮȜȜȐȗȠȣȝİ IJȘȞ IJȚȝȒ IJȠȣ ȝİIJȡȘIJȒ İʌĮȞȐȜȘȥȘȢ, ĮȣIJȒ ĮȜȜȐȗİȚ ĮȣIJȩȝĮIJĮ Įʌȩ IJȘȞ ȓįȚĮ IJȘȞ İȞIJȠȜȒ For. ǼȐȞ İʌȚșȣȝȠȪȝİ ȞĮ İʌĮȞĮȜȐȕȠȣȝİ ȝİ IJȘȞ İȞIJȠȜȒ For ʌİȡȚııȩIJİȡİȢ Įʌȩ ȝȓĮ İȞIJȠȜȑȢ, IJȩIJİ șĮ ʌȡȑʌİȚ ȞĮ ȠȝĮįȠʌȠȚȒıȠȣȝİ IJȚȢ İȞIJȠȜȑȢ ĮȣIJȑȢ ȝİ IJȚȢ ȜȑȟİȚȢ Begin țĮȚ End. ȆĮȡȐįİȚȖȝĮ: For i := 1 to 10 do Begin Writeln('ȉ.Ǽ.ǿ. ȁĮȝȓĮȢ'); Writeln('ȉȝȒȝĮ ȆȜȘȡȠijȠȡȚțȒȢ'); End; Ǿ ȝİIJĮȕȜȘIJȒ Ș ȠʌȠȓĮ ȤȡȘıȚȝȠʌȠȚİȓIJĮȚ ȦȢ ȝİIJȡȘIJȒȢ İȓȞĮȚ įȣȞĮIJȩȞ ȞĮ ȝİȚȫȞİIJĮȚ țĮIJȐ ȑȞĮ Įʌȩ țȐʌȠȚĮ ĮȡȤȚțȒ IJȚȝȒ ıİ țȐʌȠȚĮ IJİȜȚțȒ IJȚȝȒ. ȈIJȘȞ ʌİȡȓʌIJȦıȘ ȩʌȠȣ ȑȤȠȣȝİ ȝİȓȦıȘ, Ș įİıȝİȣȝȑȞȘ ȜȑȟȘ to ĮȞIJȚțĮșȓıIJĮIJĮȚ ȝİ IJȘȞ įİıȝİȣȝȑȞȘ ȜȑȟȘ downto: For ȝİIJĮȕȜȘIJȒ := ĮȡȤȚțȒ_IJȚȝȒ downto IJİȜȚțȒ_IJȚȝȒ do İȞIJȠȜȒ; 5.5 ǹıțȒıİȚȢ DZıțȘıȘ 5.1 ȃĮ ȖȡĮijİȓ ʌȡȩȖȡĮȝȝĮ, ex51.pas, IJȠ ȠʌȠȓȠ ȞĮ ĮșȡȠȓȗİȚ įȚĮįȠȤȚțȐ ʌȡĮȖȝĮIJȚțȠȪȢ ĮȡȚșȝȠȪȢ IJȠȣȢ ȠʌȠȓȠȣȢ İȚıȐȖİȚ Ƞ ȤȡȒıIJȘȢ. Ǿ İȚıĮȖȦȖȒ IJȦȞ ĮȡȚșȝȫȞ ȞĮ ıIJĮȝĮIJȐ ȩIJĮȞ Ƞ ȤȡȒıIJȘȢ ʌȜȘțIJȡȠȜȠȖȒıİȚ IJȠȞ ĮȡȚșȝȩ 0 țĮȚ ıIJȘȞ ıȣȞȑȤİȚĮ IJȠ ʌȡȩȖȡĮȝȝĮ ȞĮ İțIJȣʌȫȞİȚ ıIJȘȞ ȠșȩȞȘ IJȠ ıȣȞȠȜȚțȩ ȐșȡȠȚıȝĮ.

ǹș. Ǽ. ȀȠȣIJıȠȞȚțȩȜĮȢ


32

ǹȈȀǾȈǾ 5

DZıțȘıȘ 5.2 ȂȓĮ ȝʌȐȜĮ ĮijȒȞİIJĮȚ ȞĮ ʌȑıİȚ Įʌȩ ȑȞĮ įİįȠȝȑȞȠ ȪȥȠȢ ʌȐȞȦ Įʌȩ IJȠ ȠȡȚȗȩȞIJȚȠ İʌȓʌİįȠ țĮȚ ıİ țȐșİ ĮȞĮʌȒįȘıȘ ijIJȐȞİȚ ıIJȠ 75% IJȠȣ ȪȥȠȣȢ ʌȠȣ İȓȤİ ʌȡȠȘȖȠȣȝȑȞȦȢ. īȡȐȥIJİ ʌȡȩȖȡĮȝȝĮ, ex52.pas, ʌȠȣ ȞĮ įȑȤİIJĮȚ IJȠ ĮȡȤȚțȩ ȪȥȠȢ, ıİ ȝȑIJȡĮ, țĮȚ ȞĮ ȣʌȠȜȠȖȓȗİȚ ʌȩıİȢ ĮȞĮʌȘįȒıİȚȢ șĮ țȐȞİȚ Ș ȝʌȐȜĮ ȝȑȤȡȚ ȞĮ ıIJĮȝĮIJȒıİȚ. ĬİȦȡȒıIJİ ȩIJȚ ȠȚ ĮȞĮʌȘįȒıİȚȢ ıIJĮȝĮIJȐȞİ ȩIJĮȞ IJȠ ȪȥȠȢ IJȠȣȢ ȖȓȞİȚ ȝȚțȡȩIJİȡȠ IJȦȞ 10mm. DZıțȘıȘ 5.3 ȃĮ ȖȡĮijİȓ ʌȡȩȖȡĮȝȝĮ, ex53.pas, IJȠ ȠʌȠȓȠ țȐȞȠȞIJĮȢ ȤȡȒıȘ IJȘȢ İȞIJȠȜȒȢ Repeat, ȞĮ ȣʌȠȜȠȖȓȗİȚ Įʌȩ ʌȠȚĮ IJȚȝȒ IJȠȣ n țĮȚ ʌȐȞȦ Ș ʌĮȡȐıIJĮıȘ: 1 2 + 2 2 + 3 2 + … + n2 İȓȞĮȚ ȝİȖĮȜȪIJİȡȘ IJȠȣ 65000. DZıțȘıȘ 5.4 īȡȐȥIJİ ʌȡȩȖȡĮȝȝĮ, ex54.pas, ʌȠȣ ȞĮ ʌĮȡȐȖİȚ ȑȞĮȞ ʌȓȞĮțĮ ȝİIJĮIJȡȠʌȒȢ șİȡȝȠțȡĮıȚȫȞ Įʌȩ ȕĮșȝȠȪȢ Celsius ıİ ȕĮșȝȠȪȢ Fahrenheit ıIJȘȞ ʌİȡȚȠȤȒ Įʌȩ -40° C ȑȦȢ +40° C. ȅ IJȪʌȠȢ ȝİIJĮIJȡȠʌȒȢ İȓȞĮȚ: 5 C (F  32) ˜ 9 ȈǾȂǼǿȍȈǼǿȈ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________


ǼȞIJȠȜȑȢ ǼʌĮȞȐȜȘȥȘȢ

33

_____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________

ǹș. Ǽ. ȀȠȣIJıȠȞȚțȩȜĮȢ


34

ǹȈȀǾȈǾ 5

_____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________


35

ǹȈȀǾȈǾ 6 ȊʌȠʌȡȠȖȡȐȝȝĮIJĮ 6.1 ǼȚıĮȖȦȖȒ Ǿ ĮȞȐʌIJȣȟȘ İȞȩȢ ȝİȖȐȜȠȣ țĮȚ ʌȠȜȪʌȜȠțȠȣ ʌȡȠȖȡȐȝȝĮIJȠȢ ȖȓȞİIJĮȚ ȝİ IJȘȞ ȤȡȒıȘ ȣʌȠʌȡȠȖȡĮȝȝȐIJȦȞ. DzȞĮ ȣʌȠʌȡȩȖȡĮȝȝĮ İȓȞĮȚ ȑȞĮ ıȤİIJȚțȩ ȝȚțȡȩ țĮȚ ĮȞİȟȐȡIJȘIJȠ ʌȡȩȖȡĮȝȝĮ IJȠ ȠʌȠȓȠ ĮȞĮʌIJȪııİIJĮȚ ȖȚĮ ȞĮ İʌȚȜȪıİȚ ȑȞĮ ıȣȖțİțȡȚȝȑȞȠ ĮȣIJȠIJİȜȑȢ ʌȡȩȕȜȘȝĮ Ȓ İȡȖĮıȓĮ. ȉĮ ȣʌȠʌȡȠȖȡȐȝȝĮIJĮ İȝʌİȡȚȑȤȠȞIJĮȚ ıİ ȐȜȜĮ ʌȡȠȖȡȐȝȝĮIJĮ (ʌȠȣ ȜȑȖȠȞIJĮȚ țȪȡȚĮ ʌȡȠȖȡȐȝȝĮIJĮ) țĮȚ ȕȠȘșȠȪȞ ıIJȘȞ țĮȜȪIJİȡȘ įȩȝȘıȘ țĮȚ ȠȡȖȐȞȦıȘ IJȠȣ ʌȡȠȖȡȐȝȝĮIJȠȢ. ȉĮ ȣʌȠʌȡȠȖȡȐȝȝĮIJĮ IJȘȢ Pascal ȤȦȡȓȗȠȞIJĮȚ ıİ įȪȠ țĮIJȘȖȠȡȓİȢ: IJȚȢ įȚĮįȚțĮıȓİȢ (Procedures) țĮȚ IJȚȢ ıȣȞĮȡIJȒıİȚȢ (Functions). ȅȚ įȚĮįȚțĮıȓİȢ İʌȚIJİȜȠȪȞ țȐʌȠȚĮ ĮȣIJȠIJİȜȒ İȡȖĮıȓĮ (ʌ.Ȥ. İțIJȪʌȦıȘ ȝȘȞȣȝȐIJȦȞ ıIJȘȞ ȠșȩȞȘ) țĮȚ įİȞ İʌȚıIJȡȑijȠȣȞ țȐʌȠȚĮ IJȚȝȒ. ǹȞIJȓșİIJĮ ȠȚ ıȣȞĮȡIJȒıİȚȢ İʌȚıIJȡȑijȠȣȞ IJȚȝȒ (ʌ.Ȥ. ȩIJĮȞ ȤȡȘıȚȝȠʌȠȚȠȪȞIJĮȚ ȖȚĮ IJȠȞ ȣʌȠȜȠȖȚıȝȩ IJȠȣ İȝȕĮįȠȪ İȞȩȢ ȖİȦȝİIJȡȚțȠȪ ıȤȒȝĮIJȠȢ). ȅ ȠȡȚıȝȩȢ ȣʌȠʌȡȠȖȡĮȝȝȐIJȦȞ ı'ȑȞĮ ʌȡȩȖȡĮȝȝĮ, ȖȓȞİIJĮȚ ȝİIJȐ IJȠ IJȝȒȝĮ Var IJȠȣ ʌȡȠȖȡȐȝȝĮIJȠȢ. Ǿ įȠȝȒ İȞȩȢ ȣʌȠʌȡȠȖȡȐȝȝĮIJȠȢ ȝȠȚȐȗİȚ ȝİ IJȘȞ įȠȝȒ IJȠȣ țȣȡȓȠȣ ʌȡȠȖȡȐȝȝĮIJȠȢ, ȑȤİȚ įȘȜĮįȒ İʌȚțİijĮȜȓįĮ, IJȝȒȝĮ įȘȜȫıİȦȞ țĮȚ IJȝȒȝĮ İȞIJȠȜȫȞ, ȝȩȞȠ ʌȠȣ Ș İʌȚțİijĮȜȓįĮ ȝȚĮȢ įȚĮįȚțĮıȓĮȢ ĮȡȤȓȗİȚ ȝİ IJȘȞ ȜȑȟȘ Procedure țĮȚ ȝȚĮȢ ıȣȞȐȡIJȘıȘȢ ȝİ IJȘ ȜȑȟȘ Function, ȩʌȦȢ șĮ įȠȪȝİ ʌĮȡĮțȐIJȦ. 6.2 ǻȚĮįȚțĮıȓİȢ DzıIJȦ ȩIJȚ șȑȜȠȣȝİ ȞĮ ȣȜȠʌȠȚȒıȠȣȝİ ȝȓĮ įȚĮįȚțĮıȓĮ Ș ȠʌȠȓĮ İțIJȣʌȫȞİȚ ıIJȘȞ ȠșȩȞȘ ȝȚĮ ȖȡĮȝȝȒ ȝİ ĮıIJȑȡȚĮ. ǹȢ ȣʌȠșȑıȠȣȝİ ȩIJȚ IJȘȞ įȚĮįȚțĮıȓĮ ĮȣIJȒ IJȘȞ ȠȞȠȝȐȗȠȣȝİ PrintLine țĮȚ ȤȡȘıȚȝȠʌȠȚİȓIJĮȚ Įʌȩ IJȠ ʌȡȩȖȡĮȝȝĮ ȖȚĮ ȞĮ IJȣʌȫȞİȚ ȖȡĮȝȝȑȢ ıIJȘȞ ȠșȩȞȘ. ȉȩIJİ IJȠ ʌȡȩȖȡĮȝȝȐ ȝĮȢ șĮ İȓȞĮȚ ȩʌȦȢ ʌĮȡĮțȐIJȦ: Program Proc1; Var s: String[20]; Procedure PrintLine; Begin Writeln('**********'); End;

Begin s := 'TEI ȁǹȂǿǹȈ'; PrintLine; Writeln(s); PrintLine; End; ȉȠ ʌĮȡĮʌȐȞȦ ʌȡȩȖȡĮȝȝĮ țĮȜİȓ įȪȠ ijȠȡȑȢ IJȘȞ įȚĮįȚțĮıȓĮ PrintLine țĮȚ IJȣʌȫȞİȚ ıIJȘȞ ȠșȩȞȘ IJĮ ʌĮȡĮțȐIJȦ: ********** TEI ȁǹȂǿǹȈ ********** ȂȓĮ įȚĮįȚțĮıȓĮ, ȩʌȦȢ ȑȞĮ ʌȡȩȖȡĮȝȝĮ, ȝʌȠȡİȓ ȞĮ ȑȤİȚ įȚțȩ IJȘȢ IJȝȒȝĮ Var ȩʌȠȣ įȘȜȫȞȠȞIJĮȚ IJȠʌȚțȑȢ ȝİIJĮȕȜȘIJȑȢ. ȅȚ ȝİIJĮȕȜȘIJȑȢ ĮȣIJȑȢ ȑȤȠȣȞ ȚıȤȪ ȝȩȞȠ İȞIJȩȢ IJȘȢ įȚĮįȚțĮıȓĮȢ ıIJȘȞ ȠʌȠȓĮ ȑȤȠȣȞ įȘȜȦșİȓ țĮȚ ȜȑȖȠȞIJĮȚ IJȠʌȚțȑȢ. ǹȞIJȓșİIJĮ ȠȚ ȝİIJĮȕȜȘIJȑȢ ȠȚ ȠʌȠȓİȢ įȘȜȫȞȠȞIJĮȚ ıIJȠ IJȝȒȝĮ Var IJȠȣ țȣȡȓȦȢ ʌȡȠȖȡȐȝȝĮIJȠȢ ȑȤȠȣȞ ȚıȤȪ ıİ ȩȜȠ IJȠ ʌȡȩȖȡĮȝȝĮ țĮȚ ȜȑȖȠȞIJĮȚ țĮșȠȜȚțȑȢ.


36

ǹȈȀǾȈǾ 6

ȂʌȠȡȠȪȝİ ȞĮ IJȡȠʌȠʌȠȚȒıȠȣȝİ IJȘȞ įȚĮįȚțĮıȓĮ PrintLine ȫıIJİ ȞĮ ȤȡȘıȚȝȠʌȠȚİȓ ȝȓĮ IJȠʌȚțȒ ȝİIJĮȕȜȘIJȒ, ȩʌȦȢ ʌĮȡĮțȐIJȦ: Procedure PrintLine; Var i :Integer; Begin For i:=1 to 50 do Write('*'); Writeln; End; Ȉİ ȑȞĮ ʌȡȩȖȡĮȝȝĮ ȝʌȠȡȠȪȝİ ȞĮ ȠȡȓıȠȣȝİ țĮȚ ȞĮ ȤȡȘıȚȝȠʌȠȚȒıȠȣȝİ ʌİȡȚııȩIJİȡİȢ Įʌȩ ȝȓĮ įȚĮįȚțĮıȓİȢ. īȚĮ ʌĮȡȐįİȚȖȝĮ, ıIJȠ ʌĮȡĮțȐIJȦ ʌȡȩȖȡĮȝȝĮ, ȠȡȓȗȠȞIJĮȚ įȪȠ įȚĮįȚțĮıȓİȢ, Ș PrintLine țĮȚ Ș PrintMessage. Program Proc2; Var s: String[20]; Procedure PrintLine; Var i :Integer; Begin For i:=1 to 50 do Write('*'); Writeln; End; Procedure PrintMessage; Begin PrintLine; Writeln(s); PrintLine; End;

Begin s:= 'TEI ȁǹȂǿǹȈ'; PrintMessage; End. ǼȓȞĮȚ İʌȓıȘȢ įȣȞĮIJȩ ȞĮ ȠȡȓȗİIJĮȚ țȐʌȠȚĮ įȚĮįȚțĮıȓĮ İȞIJȩȢ țȐʌȠȚĮȢ ȐȜȜȘȢ įȚĮįȚțĮıȓĮȢ (įȘȜĮįȒ ȞĮ ȠȡȚıșİȓ ȦȢ ȣʌȠʌȡȩȖȡĮȝȝĮ ȣʌȠʌȡȠȖȡȐȝȝĮIJȠȢ). īȚĮ ʌĮȡȐįİȚȖȝĮ, ıIJȠ ʌĮȡĮțȐIJȦ ʌȡȩȖȡĮȝȝĮ ǹ ȠȡȓȗİIJĮȚ Ș įȚĮįȚțĮıȓĮ P1 ıIJȘȞ ȠʌȠȓĮ ȠȡȓȗİIJĮȚ İʌȓıȘȢ Ș įȚĮįȚțĮıȓĮ P11. Program A; Procedure P1; Procedure P11; Begin ... End; Begin ... End;

Begin ... End.


ȊʌȠʌȡȠȖȡȐȝȝĮIJĮ

37

6.3 ȆĮȡȐȝİIJȡȠȚ ǻȚĮįȚțĮıȚȫȞ ȂȓĮ įȚĮįȚțĮıȓĮ ȝʌȠȡİȓ ȞĮ įȑȤİIJĮȚ ıĮȞ ʌĮȡĮȝȑIJȡȠȣȢ țȐʌȠȚİȢ ȝİIJĮȕȜȘIJȑȢ. īȚĮ ʌĮȡȐįİȚȖȝĮ, ȝʌȠȡȠȪȝİ ȞĮ IJȡȠʌȠʌȠȚȒıoȣȝİ IJȘȞ įȚĮįȚțĮıȓĮ PrintLine ȫıIJİ ȞĮ ʌĮȡĮȝİIJȡȠʌȠȚȘșİȓ Ƞ ĮȡȚșȝȩȢ IJȦȞ ĮıIJİȡȚȫȞ Ƞ ȠʌȠȓȠȢ IJȣʌȫȞİIJĮȚ ıİ țȐșİ ȖȡĮȝȝȒ. ȍȢ ʌĮȡȐȝİIJȡȠ ȤȡȘıȚȝȠʌȠȚȠȪȝİ IJȘȞ ȝİIJĮȕȜȘIJȒ x Ș oʌȠȓĮ įȘȜȫȞİIJĮȚ İȞIJȩȢ ʌĮȡȑȞșİıȘȢ įȓʌȜĮ ıIJȠ ȩȞȠȝĮ IJȘȢ įȚĮįȚțĮıȓĮȢ: Procedure PrintLine(x :Integer); Var i :Integer; Begin For i:=1 to x do Write('*'); Writeln; End; ȂʌȠȡȠȪȝİ ȞĮ ȤȡȘıȚȝȠʌȠȚȒıȠȣȝİ ʌİȡȚııȩIJİȡİȢ Įʌȩ ȝȓĮ ʌĮȡĮȝȑIJȡȠȣȢ ıİ țȐʌȠȚĮ įȚĮįȚțĮıȓĮ. Ǿ ʌĮȡĮțȐIJȦ įȚĮįȚțĮıȓĮ, įȑȤİIJĮȚ ȦȢ ʌĮȡĮȝȑIJȡȠȣȢ įȪȠ ĮțȑȡĮȚȠȣȢ ĮȡȚșȝȠȪȢ (ȑıIJȦ X țĮȚ Y) țĮȚ IJȣʌȫȞİȚ ȑȞĮ ıȣȝʌĮȖȑȢ ȠȡșȠȖȫȞȚȠ ȝİ įȚĮıIJȐıİȚȢ X x Y ȖİȝȐIJȠ ȝİ ĮıIJİȡȐțȚĮ: Procedure PrintBox(X :Integer, Y:Integer); {įȚĮįȚțĮıȓĮ Ș ȠʌȠȓĮ IJȣʌȫȞİȚ ȑȞĮ ȠȡșȠȖȫȞȚȠ X x Y } Var i,j : Integer; Begin For i:=1 to X do Begin For j:=1 to Y do Write('*'); Writeln; End; End; ȆĮȡĮįİȓȖȝĮIJĮ țȜȒıİȦȞ IJȦȞ ʌĮȡĮʌȐȞȦ įȚĮįȚțĮıȚȫȞ ȝİ ʌĮȡĮȝȑIJȡȠȣȢ İȓȞĮȚ: PrintLine(60); PrintBox(5,5); Ș z ʌȡȑʌİȚ ȞĮ İȓȞĮȚ ȝİIJĮȕȜȘIJȒ IJȠȣ țȣȡȓȦȢ ʌȡȠȖȡȐȝȝĮIJȠȢ PrintLine(z); 6.4 ȈȣȞĮȡIJȒıİȚȢ ȅȚ ıȣȞĮȡIJȒıİȚȢ İȓȞĮȚ ʌĮȡȩȝȠȚİȢ ȝİ IJȚȢ įȚĮįȚțĮıȓİȢ. ǻȚĮijȑȡȠȣȞ ıIJȠ ȩIJȚ ȠȚ ıȣȞĮȡIJȒıİȚȢ ȝİIJȐ IJȘȞ İțIJȑȜİıȘ IJȠȣȢ İʌȚıIJȡȑijȠȣȞ țȐʌȠȚĮ IJȚȝȒ. ȅ IJȪʌȠȢ įİįȠȝȑȞȦȞ IJȘȢ IJȚȝȒȢ Ș ȠʌȠȓĮ İʌȚıIJȡȑijİIJĮȚ Įʌȩ ȝȓĮ ıȣȞȐȡIJȘıȘ ȠȡȓȗİIJĮȚ ȝĮȗȓ ȝİ IJȠ ȩȞȠȝĮ IJȘȢ ıȣȞȐȡIJȘıȘȢ, ıIJȘȞ İʌȚțİijĮȜȓįĮ IJȘȢ. Ǿ įȒȜȦıȘ ȝȚĮȢ ıȣȞȐȡIJȘıȘȢ ȖȓȞİIJĮȚ ȩʌȦȢ ĮțȡȚȕȫȢ țĮȚ Ș įȒȜȦıȘ ȝȚĮȢ įȚĮįȚțĮıȓĮȢ, ĮȜȜȐ ıIJȘȞ șȑıȘ IJȘȢ ȜȑȟȘȢ Procedure ȤȡȘıȚȝȠʌȠȚİȓIJĮȚ Ș ȜȑȟȘ Function. īȚĮ ȞĮ İʌȚıIJȡȑȥİȚ Ș ıȣȞȐȡIJȘıȘ ȝȓĮ IJȚȝȒ, șĮ ʌȡȑʌİȚ ȝȑıĮ ıIJȘ ıȣȞȐȡIJȘıȘ ȞĮ ȣʌȐȡȤİȚ ȝȚĮ İȞIJȠȜȒ țĮIJĮȤȫȡȘıȘȢ IJȘȢ IJȚȝȒȢ ıIJȠ ȩȞȠȝĮ IJȘȢ ıȣȞȐȡIJȘıȘȢ. ȈIJȠ ʌĮȡĮțȐIJȦ ʌȡȩȖȡĮȝȝĮ, Ș ıȣȞȐȡIJȘıȘ DegreesToRad įȑȤİIJĮȚ ȦȢ ʌĮȡȐȝİIJȡȠ IJȘȞ IJȚȝȒ ȝȚĮȢ ȖȦȞȓĮȢ ıİ ȝȠȓȡİȢ țĮȚ İʌȚıIJȡȑijİȚ IJȘȞ IJȚȝȒ IJȘȢ ȖȦȞȓĮȢ ıİ ĮțIJȓȞȚĮ.

Program Function1; Var z : Real; Function DegreesToRad(x:Real):Real; Begin DegreesToRad := x*3.14/180; End;

ǹș. Ǽ. ȀȠȣIJıȠȞȚțȩȜĮȢ


38

ǹȈȀǾȈǾ 6

Begin Write('ǻȫıİ ȝȓĮ ȖȦȞȓĮ ıİ ȝȠȓȡİȢ; '); Readln(z); Writeln('H ȖȦȞȓĮ ıİ ĮțIJȓȞȚĮ İȓȞĮȚ ', DegreesToRad(z)); Writeln('To ȘȝȓIJȠȞȠ IJȘȢ ȖȦȞȓĮȢ İȓȞĮȚ ', Sin(DegreesToRad(z))); End. 6.5 ǹȞĮįȡȠȝȚțȑȢ ȈȣȞĮȡIJȒıİȚȢ ǹȞĮįȡȠȝȚțȒ ıȣȞȐȡIJȘıȘ ȜȑȖİIJĮȚ Ș ıȣȞȐȡIJȘıȘ Ș ȠʌȠȓĮ țĮȜİȓ IJȠȞ İĮȣIJȩ IJȘȢ. īȚĮ ʌĮȡȐįİȚȖȝĮ, Ƞ ĮȞĮįȡȠȝȚțȩȢ ȠȡȚıȝȩȢ IJȘȢ ȣʌȠȜȠȖȓȗİȚ IJȠ ʌĮȡĮȖȠȞIJȚțȩ İȞȩȢ ĮȡȚșȝȠȪ İȓȞĮȚ:

ıȣȞȐȡIJȘıȘȢ Paragontiko Ș ȠʌȠȓĮ

Paragontiko(n) = 1

ȖȚĮ n = 0

Paragontiko(n) = n*Paragontiko(n-1)

ȖȚĮ n >= 1

ȅ ʌĮȡĮʌȐȞȦ ĮȞĮįȡȠȝȚțȩȢ ȠȡȚıȝȩȢ IJȠȣ ʌĮȡĮȖȠȞIJȚțȠȪ, ȣȜȠʌȠȚİȓIJĮȚ ȝİ IJȘȞ ĮȞĮįȡȠȝȚțȒ ıȣȞȐȡIJȘıȘ ʌȠȣ ijĮȓȞİIJĮȚ ʌĮȡĮțȐIJȦ: Function Paragontiko(n:Integer):LongInt; Begin If n = 0 then Paragontiko := 1 else Paragontiko := n * Paragontiko(n-1); End; īȚĮ ȞĮ țĮIJĮȜȐȕȠȣȝİ ʌȫȢ ȜİȚIJȠȣȡȖİȓ Ș ĮȞĮįȡȠȝȒ ıIJȘȞ ıȣȞȐȡIJȘıȘ Paragontiko, ĮȢ ȣʌȠșȑıȠȣȝİ ȩIJȚ ĮȣIJȒ Ș ıȣȞȐȡIJȘıȘ țĮȜİȓIJĮȚ ȝİ ʌĮȡȐȝİIJȡȠ IJȠȞ ĮțȑȡĮȚȠ ĮȡȚșȝȩ 5. ȉȩIJİ țĮIJȐ IJȠȞ ȣʌȠȜȠȖȚıȝȩ IJȘȢ ıȣȞȐȡIJȘıȘȢ Paragontiko(5), șĮ țȜȘșİȓ Ș ıȣȞȐȡIJȘıȘ Paragontiko(4) Ș ȠʌȠȓĮ ȝİ IJȘȞ ıİȚȡȐ IJȘȢ șĮ țĮȜȑıİȚ IJȘȞ ıȣȞȐȡIJȘıȘ Paragontiko(3) ț.Ƞ.ț. ȝȑȤȡȚ ȞĮ ijIJȐıȠȣȝİ ıIJȘȞ ıȣȞȐȡIJȘıȘ Paragontiko(0). ȈIJȠ ıȘȝİȓȠ ĮȣIJȩ ıIJĮȝĮIJȐ Ș ĮȞĮįȡȠȝȒ țĮȚ Ș ıȣȞȐȡIJȘıȘ Paragontiko(0) İʌȚıIJȡȑijİȚ IJȘȞ IJȚȝȒ 1, ıIJȘȞ ıȣȞȑȤİȚĮ ȣʌȠȜȠȖȓȗİIJĮȚ Ș ıȣȞȐȡIJȘıȘ Paragontiko(1) Ș ȠʌȠȓĮ İʌȚıIJȡȑijİȚ IJȚȝȒ ıIJȘȞ ıȣȞȐȡIJȘıȘ Paragontiko(2) ț.Ƞ.ț. ȝȑȤȡȚ ȞĮ ȣʌȠȜȠȖȚıșİȓ IJİȜİȣIJĮȓĮ Ș ıȣȞȐȡIJȘıȘ Paragontiko(5) țĮȚ ȞĮ İʌȚıIJȡȑȥİȚ IJȚȝȒ.

6.6 ǹıțȒıİȚȢ DZıțȘıȘ 6.1 ȃĮ ȖȡĮijİȓ ʌȡȩȖȡĮȝȝĮ, ex61.pas, ʌȠȣ ȞĮ įȑȤİIJĮȚ Įʌȩ IJȠ ʌȜȘțIJȡȠȜȩȖȚȠ IJȡİȚȢ ĮțȑȡĮȚȠȣȢ ĮȡȚșȝȠȪȢ ʌȠȣ șĮ įȘȜȫȞȠȣȞ IJȚȢ ȝȘȞȚĮȓİȢ ʌȦȜȒıİȚȢ İȞȩȢ ȣȜȚțȠȪ Įʌȩ IJȠȣȢ ʌȦȜȘIJȑȢ īȚȐȞȞȘ, ȂĮȡȓĮ, ǼȜȑȞȘ ĮȞIJȓıIJȠȚȤĮ. DzʌİȚIJĮ, ĮȞȐȜȠȖĮ ȝİ IJȠ ȪȥȠȢ IJȦȞ ʌȦȜȒıİȦȞ, ȞĮ IJȣʌȫȞİIJĮȚ ȖȚĮ țȐșİ ʌȦȜȘIJȒ ȝȓĮ ȠȡȚȗȩȞIJȚĮ ȖȡĮȝȝȒ ĮȞȐȜȠȖȠȣ ȝȒțȠȣȢ, ȤȡȘıȚȝȠʌȠȚȫȞIJĮȢ IJȠ ȤĮȡĮțIJȒȡĮ '='. (ȊʌȩįİȚȟȘ: ȠȡȓıIJİ ȝȓĮ įȚĮįȚțĮıȓĮ Ș ȠʌȠȓĮ ȞĮ įȑȤİIJĮȚ ȦȢ ʌĮȡȐȝİIJȡȠ ȑȞĮȞ ĮțȑȡĮȚȠ ĮȡȚșȝȩ țĮȚ ȞĮ İțIJȣʌȫȞİȚ ĮȞȐȜȠȖĮ '='. ȈIJȘȞ ıȣȞȑȤİȚĮ ȝʌȠȡİȓIJİ ȞĮ țĮȜȑıİIJİ ĮȣIJȒ IJȘȞ įȚĮįȚțĮıȓĮ IJȡİȚȢ ijȠȡȑȢ ıIJȠ țȣȡȓȦȢ ʌȡȩȖȡĮȝȝĮ). DZıțȘıȘ 6.2 ȃĮ ȖȡĮijİȓ ʌȡȩȖȡĮȝȝĮ, ex62.pas, IJȠ ȠʌȠȓȠ ȞĮ ȠȡȓȗİȚ įȚĮįȚțĮıȓĮ ȝİ IJȠ ȩȞȠȝĮ PrintFrame Ș ȠʌȠȓĮ ȞĮ IJȣʌȫȞİȚ ȑȞĮ ʌȜĮȓıȚȠ įȚĮıIJȐıİȦȞ n x m, ȤȡȘıȚȝȠʌȠȚȫȞIJĮȢ IJȠ ȤĮȡĮțIJȒȡĮ '*'. ȉȠ ʌȡȩȖȡĮȝȝĮ ȞĮ ȗȘIJȐ Įʌȩ IJȠȞ ȤȡȒıIJȘ ȞĮ İȚıȐȖİȚ IJȠȣȢ ĮȡȚșȝȠȪȢ n țĮȚ m, țĮȚ ıIJȘȞ ıȣȞȑȤİȚĮ ȞĮ țĮȜİȓ IJȘȞ įȚĮįȚțĮıȓĮ PrintFrame.


ȊʌȠʌȡȠȖȡȐȝȝĮIJĮ

39

DZıțȘıȘ 6.3 ȃĮ ȖȡĮijİȓ ʌȡȩȖȡĮȝȝĮ, ex63.pas, ıIJȠ ȠʌȠȓȠ ȞĮ ȠȡȓȗİIJĮȚ ȝȓĮ ıȣȞȐȡIJȘıȘ ȝİ ȩȞȠȝĮ power Ș ȠʌȠȓĮ ȞĮ ȕȡȓıțİȚ țĮȚ ȞĮ İʌȚıIJȡȑijİȚ IJȘ įȪȞĮȝȘ İȞȩȢ ʌȡĮȖȝĮIJȚțȠȪ ĮȡȚșȝȠȪ ȣȥȦȝȑȞȠȣ ı'ȑȞĮȞ ĮțȑȡĮȚȠ İțșȑIJȘ. Ǿ ıȣȞȐȡIJȘıȘ (ʌȡȠijĮȞȫȢ) șĮ įȑȤİIJĮȚ įȪȠ ʌĮȡĮȝȑIJȡȠȣȢ IJȘȞ ȕȐıȘ țĮȚ IJȠȞ İțșȑIJȘ. ȉȠ ʌȡȩȖȡĮȝȝĮ ȞĮ ȗȘIJȐ Įʌȩ IJȠȞ ȤȡȒıIJȘ ȞĮ įȫıİȚ IJȘȞ ȕȐıȘ țĮȚ IJȠȞ İțșȑIJȘ țĮȚ ıIJȘȞ ıȣȞȑȤİȚĮ țȐȞȠȞIJĮȢ ȤȡȒıȘ IJȘȢ power ȞĮ İȝijĮȞȓȗİȚ ıIJȘȞ ȠșȩȞȘ IJȠ ĮʌȠIJȑȜİıȝĮ. DZıțȘıȘ 6.4 īȡȐȥIJİ ȑȞĮ ʌȡȩȖȡĮȝȝĮ, ex64.pas, ʌȠȣ ȞĮ ȣʌȠȜȠȖȓȗİȚ IJĮ İȝȕĮįȐ IJȦȞ İȟȒȢ ıȤȘȝȐIJȦȞ: ȠȡșȠȖȦȞȓȠȣ ʌĮȡĮȜȜȘȜȠȖȡȐȝȝȠȣ, țȪțȜȠȣ, IJȡȚȖȫȞȠȣ țĮȚ IJȡĮʌİȗȓȠȣ. Ǿ İʌȚȜȠȖȒ ȖȚĮ IJȠ ʌȠȚȠȣ ıȤȒȝĮIJȠȢ IJȠ İȝȕĮįȩȞ șĮ ȣʌȠȜȠȖȚıIJİȓ, ȞĮ ȖȓȞİIJĮȚ ȝȑıĮ Įʌȩ ȑȞĮ menu İʌȚȜȠȖȫȞ. ȅȚ İʌȚȜȠȖȑȢ IJȠȣ menu ȞĮ țĮȜȠȪȞ țĮIJȐȜȜȘȜİȢ ıȣȞĮȡIJȒıİȚȢ ʌȠȣ ȞĮ ȣʌȠȜȠȖȓȗȠȣȞ IJȠ ĮȞIJȓıIJȠȚȤȠ İȝȕĮįȩȞ. ȈǾȂǼǿȍȈǼǿȈ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________

ǹș. Ǽ. ȀȠȣIJıȠȞȚțȩȜĮȢ


40

ǹȈȀǾȈǾ 6

_____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________


41

ǹȈȀǾȈǾ 7 ȂȠȞȐįİȢ 7.1 ǼȚıĮȖȦȖȒ ȂȓĮ ȝȠȞȐįĮ İȓȞĮȚ ȝȓĮ ıȣȜȜȠȖȒ İȞȩȢ Ȓ ʌİȡȚııȠIJȑȡȦȞ ȣʌȠʌȡȠȖȡĮȝȝȐIJȦȞ, IJĮ ȠʌȠȓĮ ȝʌȠȡȠȪȞ ȞĮ ȤȡȘıȚȝȠʌȠȚȘșȠȪȞ Įʌȩ ȠʌȠȚȠįȒʌȠIJİ ʌȡȩȖȡĮȝȝĮ IJȘȢ Pascal, IJȠ ȠʌȠȓȠ țȐȞİȚ ȤȡȒıȘ IJȘȢ ȝȠȞȐįĮȢ ȝİ IJȘȞ İȞIJȠȜȒ: Uses ȩȞȠȝĮ_ȝȠȞȐįĮȢ; Ș ȠʌȠȓĮ IJȠʌȠșİIJİȓIJĮȚ ȝİIJȐ IJȘȞ İʌȚțİijĮȜȓįĮ IJȠȣ ʌȡȠȖȡȐȝȝĮIJȠȢ. ȅȚ ȝȠȞȐįİȢ ȤȡȘıȚȝȠʌȠȚȠȪȞIJĮȚ ʌȡȠțİȚȝȑȞȠȣ ȞĮ įȚĮȤȦȡȚıIJİȓ ȑȞĮ ȝİȖȐȜȠ ʌȡȩȖȡĮȝȝĮ ıİ İȞȩIJȘIJİȢ (modules). ǼʌȓıȘȢ ȤȡȘıȚȝȠʌȠȚȠȪȞIJĮȚ ȖȚĮ ȞĮ įȘȝȚȠȣȡȖȘșȠȪȞ ȕȚȕȜȚȠșȒțİȢ ȣʌȠʌȡȠȖȡĮȝȝȐIJȦȞ IJĮ ȠʌȠȓĮ ȞĮ İȓȞĮȚ įȚĮșȑıȚȝĮ ıİ ȠʌȠȚȠįȒʌȠIJİ ʌȡȩȖȡĮȝȝĮ. ȊʌȐȡȤȠȣȞ ȠȡȚıȝȑȞİȢ ȝȠȞȐįİȢ ʌȠȣ ʌİȡȚȑȤȠȞIJĮȚ ıIJȘȞ Turbo Pascal, ȝİȡȚțȑȢ Įʌȩ ĮȣIJȑȢ İȓȞĮȚ ȠȚ: DOS, CRT, Printer, Overlay, Graph. ȅȚ ȝȠȞȐįİȢ ĮȣIJȑȢ İȓȞĮȚ İȞıȦȝĮIJȦȝȑȞİȢ ıIJȠ ĮȡȤİȓȠ TURBO.TPL. ǼȓȞĮȚ įȣȞĮIJȩȞ İʌȓıȘȢ ȞĮ țĮIJĮıțİȣȐıȠȣȝİ įȚțȑȢ ȝĮȢ ȝȠȞȐįİȢ ȠȚ ȠʌȠȓİȢ ȞĮ ʌİȡȚȜĮȝȕȐȞȠȣȞ ȤȡȒıȚȝİȢ įȚĮįȚțĮıȓİȢ țĮȚ ıȣȞĮȡIJȒıİȚȢ IJȚȢ ȠʌȠȓİȢ ȤȡȘıȚȝȠʌȠȚȠȪȝİ IJĮțIJȚțȐ ıIJĮ ʌȡȠȖȡȐȝȝĮIJĮ ȝĮȢ. 7.2 ȀĮIJĮıțİȣȒ ȂȠȞȐįȦȞ ǵʌȦȢ ȑȞĮ ʌȡȩȖȡĮȝȝĮ IJȘȢ Pascal, ȑIJıȚ țĮȚ ȝȓĮ ȝȠȞȐįĮ, ĮʌȠIJİȜİȓIJĮȚ Įʌȩ įȚȐijȠȡĮ IJȝȒȝĮIJĮ, IJĮ ȠʌȠȓĮ ȑȤȠȣȞ ıȣȖțİțȡȚȝȑȞȠȣȢ ȡȩȜȠȣȢ. Ǿ įȠȝȒ ȝȚĮȢ ȝȠȞȐįĮȢ İȓȞĮȚ Ș ʌĮȡĮțȐIJȦ: Unit ȅȞȠȝĮ; {ȅȞȠȝĮ ȝȠȞȐįĮȢ }

Interface Uses ... Const ... Type ... Var ... Procedure Function

{ȉȝȒȝĮ įȘȝȠıȓȦȞ įȘȜȫıİȦȞ Ȓ IJȝȒȝĮ įȚİʌĮijȒȢ} ; {ǹȜȜİȢ ȝȠȞȐįİȢ} ; {ȈIJĮșİȡȑȢ} ; {ȉȪʌȠȚ įİįȠȝȑȞȦȞ} ; {ȂİIJĮȕȜȘIJȑȢ} ... ; {ǻȚĮįȚțĮıȓİȢ} ... ; {ȈȣȞĮȡIJȒıİȚȢ}

Implementation Const ... ; Type ... ; Var ... ; Procedure ... ; Function ... ;

{ȉȝȒȝĮ ȚįȚȦIJȚțȫȞ įȘȜȫıİȦȞ, Ȓ IJȝȒȝĮ ȣȜȠʌȠȓȘıȘȢ} {ȈIJĮșİȡȑȢ} {ȉȪʌȠȚ įİįȠȝȑȞȦȞ} {ȂİIJĮȕȜȘIJȑȢ} {ǻȚĮįȚțĮıȓİȢ} {ȈȣȞĮȡIJȒıİȚȢ}

Begin İȞIJȠȜȒ; ... İȞIJȠȜȒ; End. ȉȠ ȩȞȠȝĮ IJȘȢ ȝȠȞȐįĮȢ țĮșȠȡȓȗİIJĮȚ ıIJȘȞ İʌȚțİijĮȜȓįĮ ʌȠȣ ȟİțȚȞȐ ȝİ IJȘȞ ȜȑȟȘ Unit. ȅȚ ʌİȡȚȠȡȚıȝȠȓ ȠȚ ȠʌȠȓȠȚ ȚıȤȪȠȣȞ ȖȚĮ IJȠ ȩȞȠȝĮ ȝȚĮȢ ȝȠȞȐįĮȢ İȓȞĮȚ ȠȚ ȓįȚȠȚ ȝİ IJȠȣȢ ʌİȡȚȠȡȚıȝȠȪȢ ȠȚ ȠʌȠȓȠȚ ȚıȤȪȠȣȞ ȖȚĮ IJȠ ȩȞȠȝĮ İȞȩȢ ʌȡȠȖȡȐȝȝĮIJȠȢ IJȘȢ Pascal.


42

ǹȈȀǾȈǾ 7

ȈIJȠ IJȝȒȝĮ Interface ȖȓȞİIJĮȚ ʌȡȠĮȚȡİIJȚțȐ Ș įȒȜȦıȘ ȐȜȜȦȞ ȝȠȞȐįȦȞ ȠȚ ȠʌȠȓİȢ șĮ ȤȡȘıȚȝȠʌȠȚȘșȠȪȞ țĮȚ ȠȚ įȘȜȫıİȚȢ IJȪʌȦȞ įİįȠȝȑȞȦȞ, ıIJĮșİȡȫȞ, ȝİIJĮȕȜȘIJȫȞ, įȚĮįȚțĮıȚȫȞ țĮȚ ıȣȞĮȡIJȒıİȦȞ. ǵ,IJȚ įȘȜȫıİȚȢ ʌİȡȚȑȤȠȞIJĮȚ ıIJȠ IJȝȒȝĮ ĮȣIJȩ țĮȜȠȪȞIJĮȚ įȘȝȩıȚİȢ Ȓ ȠȡĮIJȑȢ įȚȩIJȚ ȝʌȠȡȠȪȞ ȞĮ ȤȡȘıȚȝȠʌȠȚȘșȠȪȞ Įʌȩ ȐȜȜĮ ʌȡȠȖȡȐȝȝĮIJĮ ʌȠȣ țȐȞȠȣȞ ȤȡȒıȘ IJȘȢ ȝȠȞȐįĮȢ ĮȣIJȒȢ. ȉȠ IJȝȒȝĮ Interface İȓȞĮȚ ȩȝȠȚȠ ȝİ IJȠ IJȝȒȝĮ įȘȜȫıİȦȞ İȞȩȢ ʌȡȠȖȡȐȝȝĮIJȠȢ ȝİ ȝȓĮ ȝȩȞȠ įȚĮijȠȡȐ: ȈIJȘȞ ʌİȡȓʌIJȦıȘ IJȦȞ įȚĮįȚțĮıȚȫȞ țĮȚ ıȣȞĮȡIJȒıİȦȞ ȖȡȐijİIJĮȚ ȝȩȞȠ Ș İʌȚțİijĮȜȓįĮ IJȠȣȢ, IJĮ ȣʌȠʌȡȠȖȡȐȝȝĮIJĮ ĮȣIJȐ țĮșĮȣIJȐ ȣʌȐȡȤȠȣȞ ʌȜȒȡȘ ıIJȠ IJȝȒȝĮ Implementation. ȈIJȠ IJȝȒȝĮ Implementation ȖȓȞİIJĮȚ, İʌȓıȘȢ ʌȡȠĮȚȡİIJȚțȐ, įȒȜȦıȘ IJȪʌȦȞ įİįȠȝȑȞȦȞ, ıIJĮșİȡȫȞ, ȝİIJĮȕȜȘIJȫȞ. ȅȚ įȘȜȫıİȚȢ IJȠȣ IJȝȒȝĮIJȠȢ Interface İȓȞĮȚ ȠȡĮIJȑȢ ıIJȠ IJȝȒȝĮ Implementation, İȞȫ ȠȚ įȘȜȫıİȚȢ IJȠȣ IJȝȒȝĮIJȠȢ Implementation įİȞ İȓȞĮȚ ȠȡĮIJȑȢ ȠȪIJİ ıIJȠ IJȝȒȝĮ Interface ȠȪIJİ ıIJȠ ʌȡȩȖȡĮȝȝĮ ʌȠȣ țȐȞİȚ ȤȡȒıȘ IJȘȢ ȝȠȞȐįĮȢ. ǵʌȦȢ ʌȡȠĮȞĮijȑȡșȘțİ, ıIJȠ IJȝȒȝĮ Implementation ȣȜȠʌȠȚȠȪȞIJĮȚ țĮȞȠȞȚțȐ ȠȚ įȚĮįȚțĮıȓİȢ țĮȚ ıȣȞĮȡIJȒıİȚȢ IJȦȞ ȠʌȠȓȦȞ ȠȚ İʌȚțİijĮȜȓįİȢ ȝȩȞȠ ȣʌȐȡȤȠȣȞ ıIJȠ IJȝȒȝĮ Interface. ȆȡȚȞ IJȠ IJȑȜȠȢ IJȠȣ ʌȡȠȖȡȐȝȝĮIJȠȢ ȝʌȠȡȠȪȝİ ȞĮ ȑȤȠȣȝİ, ʌȡȠĮȚȡİIJȚțȐ, țĮȚ ȑȞĮ IJȝȒȝĮ Begin .. End (ȩʌȦȢ ȑȤȠȣȝİ țĮȚ ıİ țĮȞȠȞȚțȐ ʌȡȠȖȡȐȝȝĮIJĮ IJȘȢ Pascal) IJȠ ȠʌȠȓȠ İțIJİȜİȓIJĮȚ ȩIJĮȞ țĮȜİȓIJĮȚ Ș ȝȠȞȐįĮ ȖȚĮ IJȘȞ ĮʌȩįȠıȘ ĮȡȤȚțȫȞ IJȚȝȫȞ ıIJȚȢ ȝİIJĮȕȜȘIJȑȢ IJȘȢ ȝȠȞȐįĮȢ. 7.3 ȆĮȡȐįİȚȖȝĮ ȂȠȞȐįĮȢ Ǿ ʌĮȡĮțȐIJȦ ȝȠȞȐįĮ ȠȡȓȗİȚ ıȣȞĮȡIJȒıİȚȢ ȖȚĮ IJȠȞ ȣʌȠȜȠȖȚıȝȩ IJȦȞ İȝȕĮįȫȞ IJİııȐȡȦȞ įȚĮijȠȡİIJȚțȫȞ ȖİȦȝİIJȡȚțȫȞ ıȤȘȝȐIJȦȞ. ȉȠ ȩȞȠȝĮ IJȘȢ ȝȠȞȐįĮȢ İȓȞĮȚ Areas țĮȚ ʌȡȑʌİȚ ȞĮ ĮʌȠșȘțİȣIJİȓ ıİ ĮȡȤİȓȠ ȝİ ȩȞȠȝĮ Areas.pas (țȐșİ ȝȠȞȐįĮ ʌȡȑʌİȚ ȞĮ ĮʌȠșȘțİȪİIJĮȚ ıİ ĮȡȤİȓȠ ȝİ ȩȞȠȝĮ ȓįȚȠ ȝİ IJȠ ȩȞȠȝĮ IJȘȢ ȝȠȞȐįĮȢ). Ǿ ȝȠȞȐįĮ ĮȣIJȒ (ȩʌȦȢ țĮȚ țȐșİ ȝȠȞȐįĮ İȟȐȜȜȠȣ) įİȞ ȝʌȠȡİȓ ȞĮ İțIJİȜİıșİȓ Įʌȩ ȝȩȞȘ IJȘȢ ʌĮȡȐ ȝȩȞȠ ȞĮ țȜȘșİȓ Įʌȩ țȐʌȠȚȠ ȐȜȜȠ ʌȡȩȖȡĮȝȝĮ IJȠ ȠʌȠȓȠ IJȘȞ ȤȡȘıȚȝȠʌȠȚİȓ. īȚĮ IJȘȞ ȤȡȒıȘ IJȘȢ Įʌȩ țȐʌȠȚȠ ȐȜȜȠ ʌȡȩȖȡĮȝȝĮ ʌȡȑʌİȚ ȞĮ įȘȝȚȠȣȡȖȘșİȓ IJȠ ĮȡȤİȓȠ Areas.tpu. īȚĮ IJȘȞ įȘȝȚȠȣȡȖȓĮ ĮȣIJȠȪ IJȠȣ ĮȡȤİȓȠȣ ʌȡȑʌİȚ ȞĮ İȓȞĮȚ İȞİȡȖȠʌȠȚȘȝȑȞȘ Ș İʌȚȜȠȖȒ Destination Disk ıIJȠ ȝİȞȠȪ Compile (İȐȞ İȝijĮȞȓȗİIJĮȚ ıIJȘ șȑıȘ IJȘȢ Ș İʌȚȜȠȖȒ Destination Memory, IJȩIJİ ĮʌȜȐ İʌȚȜȑȖȠȣȝİ IJȘȞ İʌȚȜȠȖȒ Destination Memory țĮȚ ʌĮIJȐȝİ ENTER, ȠʌȩIJİ ĮȣIJȒ ĮȜȜȐȗİȚ). ȈIJȘȞ ıȣȞȑȤİȚĮ Įʌȩ IJȠ ȝİȞȠȪ Compile İʌȚȜȑȖȠȣȝİ Make.

Unit Areas; Interface {ȉȝȒȝĮ įȚİʌĮijȒȢ} Function Circle(Radius:Real):Real; {ǻȘȝȩıȚİȢ įȘȜȫıİȚȢ} Function Square(Length:Real):Real; {ȠȡĮIJȑȢ ıIJȠ ʌȡȩ- } Function Orthogon(Length,Width:Real):Real; {ȖȡĮȝȝĮ ʌȠȣ țĮȜİȓ } Function Triangle(Base,Height:Real):Real; {IJȘ ȝȠȞȐįĮ } Implementation Var Pi_Value:Real;

{ȉȝȒȝĮ ȣȜȠʌȠȓȘıȘȢ}

{ǿįȚȦIJȚțȑȢ įȘȜȫıİȚȢ, ĮȩȡĮIJİȢ Įʌȩ IJȠ} {ʌȡȩȖȡĮȝȝĮ ʌȠȣ țĮȜİȓ IJȘ ȝȠȞȐįĮ } {******************************************************} Procedure Product(A1,A2: Real; Var Result: Real); Begin Result:= A1*A2 End; {Product} {******************************************************} Function Circle; Var R2: Real; Begin Product(Radius,Radius,R2);


ȂȠȞȐįİȢ

43

Circle := R2 * Pi_Value End; {Circle} {******************************************************} Function Square; Begin Square := Length * Length End; {Square} {******************************************************} Function Orthogon; Begin Orthogon := Length * Width End; {Orthogon} {******************************************************} Function Triangle; Begin Triangle := Base * Height / 2 End; {Triangle} BEGIN PI_Value:= 3.14159267 END. {ȉȘȢ ȝȠȞȐįĮȢ}

{ȉȝȒȝĮ ĮȡȤȚțȫȞ IJȚȝȫȞ}

ȉȠ ʌĮȡĮțȐIJȦ ʌȡȩȖȡĮȝȝĮ țȐȞİȚ ȤȡȒıȘ IJȘȢ ȝȠȞȐįĮȢ Areas.tpu ȖȚĮ IJȠȞ ȣʌȠȜȠȖȚıȝȩ İȝȕĮįȫȞ įȚĮijȩȡȦȞ ıȤȘȝȐIJȦȞ: Program Embada; Uses Areas, Crt; Var Epil: Char; M, P, Y, B, A: Real; {ȝȒțȠȢ, ʌȜȐIJȠȢ, ȪȥȠȢ, ȕȐıȘ, ĮțIJȓȞĮ} Begin Repeat Repeat Clrscr; Writeln('1. ǼȝȕĮįȩȞ IJİIJȡĮȖȫȞȠȣ'); Writeln('2. ǼȝȕĮįȩȞ IJȡȚȖȫȞȠȣ'); Writeln('3. ǼȝȕĮįȩȞ țȪțȜȠȣ'); Writeln('4. ǼȝȕĮįȩȞ ȠȡșȠȖȦȞȓȠȣ'); Writeln('5. ǼȟȠįȠȢ'); Writeln; Write('ǼʌȚȜȠȖȒ... '); Epil:=Readkey Until Epil In ['1','2','3','4','5']; Writeln; Writeln; Write('ȉȠ ıȤȒȝĮ İȓȞĮȚ IJȠ '); Case Epil of '1': Begin Writeln('IJİIJȡȐȖȦȞȠ'); Write('ǻȫıİ IJȠ ȝȒțȠȢ IJȘȢ ʌȜİȣȡȐȢ '); Readln(M); Writeln('ȉȠ İȝȕĮįȩȞ İȓȞĮȚ ', Square(M):5:2); Repeat Until Keypressed End; '2': Begin Writeln('IJȡȓȖȦȞȠ');

ǹș. Ǽ. ȀȠȣIJıȠȞȚțȩȜĮȢ


44

ǹȈȀǾȈǾ 7

Write('ǻȫıİ IJȘ ȕȐıȘ '); Readln(B); Write('ǻȫıİ IJȠ ȪȥȠȢ '); Readln(Y); Writeln('ȉȠ İȝȕĮįȩȞ İȓȞĮȚ ', Triangle(B,Y):5:2); Repeat Until Keypressed End; '3': Begin Writeln('țȪțȜȠȢ'); Write('ǻȫıİ IJȘȞ ĮțIJȓȞĮ '); Readln(A); Writeln('ȉȠ İȝȕĮįȩȞ İȓȞĮȚ ', Circle(A):5:2); Repeat Until Keypressed End; '4': Begin Writeln('ȠȡșȠȖȫȞȚȠ'); Write('ǻȫıİ IJȠ ȝȒțȠȢ '); Readln(M); Write('ǻȫıİ IJȠ ʌȜȐIJȠȢ '); Readln(P); Writeln('ȉȠ İȝȕĮįȩȞ İȓȞĮȚ ', Orthogon(M,P):5:2); Repeat Until Keypressed End End; Until Epil='5' End. 7.4 ǹıțȒıİȚȢ DZıțȘıȘ 7.1 ȀĮIJĮıțİȣȐıIJİ ȝȚĮ ȝȠȞȐįĮ ȝİ ȩȞȠȝĮ MyUnit71. Ǿ ȝȠȞȐįĮ ĮȣIJȒ șĮ ʌȡȑʌİȚ ȞĮ įȚĮșȑIJİȚ IJȚȢ ıȣȞĮȡIJȒıİȚȢ țĮȚ įȚĮįȚțĮıȓİȢ IJȘȢ ȝȠȞȐįĮȢ Areas, ʌȠȣ ʌİȡȚȖȡȐijȘțİ ʌĮȡĮʌȐȞȦ, țĮșȫȢ țĮȚ ıȣȞĮȡIJȒıİȚȢ ȖȚĮ IJȠȞ ȣʌȠȜȠȖȚıȝȩ İȝȕĮįȠȪ IJȡĮʌİȗȓȠȣ țĮȚ ȑȜȜİȚȥȘȢ. ȊʌİȞșȣȝȓȗİIJĮȚ ȩIJȚ IJȠ İȝȕĮįȩȞ İȞȩȢ IJȡĮʌİȗȓȠȣ İȓȞĮȚ Ǽ=(B1+B2)*Y/2, ȩʌȠȣ Ǻ1 țĮȚ Ǻ2 ȠȚ įȪȠ ȕȐıİȚȢ IJȠȣ IJȡĮʌİȗȓȠȣ țĮȚ Ȋ IJȠ ȪȥȠȢ IJȠȣ. ǼʌȓıȘȢ IJȠ İȝȕĮįȩȞ IJȘȢ ȑȜȜİȚȥȘȢ İȓȞĮȚ E=ʌ*R1*R2, ȩʌȠȣ R1 țĮȚ R2 İȓȞĮȚ ȠȚ ĮțIJȓȞİȢ IJȘȢ ȑȜȜİȚȥȘȢ. DZıțȘıȘ 7.2 īȡȐȥIJİ ʌȡȩȖȡĮȝȝĮ ex72.pas IJȠ ȠʌȠȓȠ țȐȞȠȞIJĮȢ ȤȡȒıȘ IJȘȢ ȝȠȞȐįĮȢ MyUnit71, ȞĮ ȣʌȠȜȠȖȓȗİȚ İȝȕĮįȐ ıȤȘȝȐIJȦȞ. ȈǾȂǼǿȍȈǼǿȈ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________


45

ǹȈȀǾȈǾ 8 ȅȡȚȗȩȝİȞȠȚ ȉȪʌȠȚ ǻİįȠȝȑȞȦȞ 8.1 ǼȚıĮȖȦȖȒ ȂȑȤȡȚ IJȫȡĮ ȑȤȠȣȝİ įİȚ țĮȚ ȤȡȘıȚȝȠʌȠȚȒıİȚ IJȠȣȢ ȕĮıȚțȠȪȢ IJȪʌȠȣȢ įİįȠȝȑȞȦȞ IJȘȢ Pascal (Integer, Real, Char țĮȚ Boolean) țĮșȫȢ țĮȚ IJȠȞ IJȪʌȠ String ȖȚĮ IJĮ ĮȜijĮȡȚșȝȘIJȚțȐ. ȍıIJȩıȠ, Ƞ ȤȡȒıIJȘȢ ȝʌȠȡİȓ ȞĮ ȠȡȓıİȚ IJȠȣȢ įȚțȠȪȢ IJȠȣ IJȪʌȠȣȢ įİįȠȝȑȞȦȞ ı'ȑȞĮ ʌȡȩȖȡĮȝȝĮ. ȅ ȠȡȚıȝȩȢ ȞȑȦȞ IJȪʌȦȞ ȖȓȞİIJĮȚ ıIJȠ IJȝȒȝĮ įȒȜȦıȘȢ IJȪʌȦȞ, IJȠ ȠʌȠȓȠ ȕȡȓıțİIJĮȚ ȝİIJȐ IJȠ IJȝȒȝĮ įȒȜȦıȘȢ ıIJĮșİȡȫȞ țĮȚ ʌȡȚȞ Įʌȩ IJȠ IJȝȒȝĮ įȒȜȦıȘȢ IJȦȞ ȝİIJĮȕȜȘIJȫȞ. ȉȠ IJȝȒȝĮ ĮȣIJȩ ȑȤİȚ IJȘȞ İʌȚțİijĮȜȓįĮ Type țĮȚ Ș įȒȜȦıȘ IJȦȞ ȠȞȠȝȐIJȦȞ IJȦȞ ȞȑȦȞ IJȪʌȦȞ ȖȓȞİIJĮȚ ȩʌȦȢ ijĮȓȞİIJĮȚ ʌĮȡĮțȐIJȦ: Type ȩȞȠȝĮ_IJȪʌȠȣ1 = IJȪʌȠȢ1; ȩȞȠȝĮ_IJȪʌȠȣ2 = IJȪʌȠȢ2; .. .. .. .. ȩȞȠȝĮ_IJȪʌȠȣn = IJȪʌȠȢn; ǹʌȩ IJȘ ıIJȚȖȝȒ ʌȠȣ ȑȤȠȣȝİ ȠȡȓıİȚ ȑȞĮ įȚțȩ ȝĮȢ IJȪʌȠ, ȝʌȠȡȠȪȝİ ȞĮ ȠȡȓıȠȣȝİ ıIJȠ ʌȡȩȖȡĮȝȝȐ ȝĮȢ ȝİIJĮȕȜȘIJȑȢ ĮȣIJȠȪ IJȠȣ IJȪʌȠȣ. 8.2 ǹʌĮȡȚșȝȘIJȠȓ ȉȪʌȠȚ ǻİįȠȝȑȞȦȞ ȈȣȤȞȐ ȣʌȐȡȤİȚ Ș ĮȞȐȖțȘ ȠȡȚıȝȠȪ İȞȩȢ ȞȑȠȣ IJȪʌȠȣ įİįȠȝȑȞȦȞ IJȠȣ ȠʌȠȓȠȣ IJȠ ʌİįȓȠ IJȚȝȫȞ İȓȞĮȚ ȝȚĮ ȜȓıIJĮ ıȣȝȕȠȜȚțȫȞ ȠȞȠȝȐIJȦȞ (ʌ.Ȥ. ȠȚ ȝȑȡİȢ IJȘȢ İȕįȠȝȐįĮȢ, ȠȚ ȝȒȞİȢ, ț.Ȝ.ʌ.). Ǿ Pascal ȝĮȢ įȓȞİȚ IJȘȞ įȣȞĮIJȩIJȘIJĮ ȞĮ ȠȡȓıȠȣȝİ ȞȑȠȣȢ IJȪʌȠȣȢ įİįȠȝȑȞȦȞ, ĮʌĮȡȚșȝȫȞIJĮȢ IJȚȢ IJȚȝȑȢ IJȠȣȢ, ȝİ IJȘȞ ʌĮȡĮțȐIJȦ įȒȜȦıȘ: ȩȞȠȝĮ_IJȪʌȠȣ = (ȜȓıIJĮ IJȚȝȫȞ); ȆĮȡȐįİȚȖȝĮ: Type Weekday = (Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday);

Month

= (Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec); ȈȘȝİȚȫıIJİ ȩIJȚ ȝİ IJȚȢ ʌĮȡĮʌȐȞȦ įȘȜȫıİȚȢ ȠȡȓȗȠȣȝİ ȞȑȠȣȢ IJȪʌȠȣȢ įİįȠȝȑȞȦȞ țĮȚ ȩȤȚ ȝİIJĮȕȜȘIJȑȢ. īȚĮ ȞĮ ȤȡȘıȚȝȠʌȠȚȒıȠȣȝİ ȝȓĮ ȝİIJĮȕȜȘIJȒ Ș ȠʌȠȓĮ ʌĮȡȚıIJȐȞİȚ ȖȚĮ ʌĮȡȐįİȚȖȝĮ țȐʌȠȚĮ ȘȝȑȡĮ IJȘȢ İȕįȠȝȐįĮȢ șĮ ʌȡȑʌİȚ ȞĮ ȤȡȘıȚȝȠʌȠȚȒıȠȣȝİ IJȘȞ ʌĮȡĮțȐIJȦ įȒȜȦıȘ: Var x : Weekday; {x ȝİIJĮȕȜȘIJȒ IJȪʌȠȣ Weekday} ȅȚ ĮʌĮȡȚșȝȘIJȠȓ IJȪʌȠȚ įİįȠȝȑȞȦȞ İȓȞĮȚ IJĮțIJȚțȠȓ IJȪʌȠȚ, Ș įİ įȚȐIJĮȟȘ IJȦȞ IJȚȝȫȞ IJȠȣȢ țĮșȠȡȓȗİIJĮȚ Įʌȩ IJȘ ıİȚȡȐ ȝİ IJȘȞ ȠʌȠȓĮ ĮȣIJȑȢ İȝijĮȞȓȗȠȞIJĮȚ ıIJȘ ȜȓıIJĮ IJȚȝȫȞ ıIJȘ įȒȜȦıȘ IJȠȣ IJȪʌȠȣ. ǼʌȠȝȑȞȦȢ ȝʌȠȡȠȪȝİ ȞĮ ȤȡȘıȚȝȠʌȠȚȒıȠȣȝİ IJȚȢ ıȣȞĮȡIJȒıİȚȢ ȅrd, Pred, Succ, Inc țĮȚ Dec (ʌȠȣ ȑȤȠȣȝİ įİȚ ıIJȘȞ DZıțȘıȘ 3) ȖȚĮ IJȘȞ İʌİȟİȡȖĮıȓĮ IJȠȣȢ. ǻİȞ İȓȞĮȚ ȩȝȦȢ įȣȞĮIJȒ Ș ȤȡȒıȘ IJȦȞ ıȣȞĮȡIJȒıİȦȞ Read, Readln, Write, țĮȚ Writeln ȖȚĮ ȞĮ įȚĮȕȐıȠȣȝİ Ȓ ȞĮ İțIJȣʌȫıȠȣȝİ IJȚȝȑȢ ĮʌĮȡȚșȝȘIJȠȪ IJȪʌȠȣ įİįȠȝȑȞȦȞ. 8.3 ȉȪʌȠȚ ȊʌȠʌİȡȚȠȤȒȢ ǼȓȞĮȚ įȣȞĮIJȩȞ ȞĮ ȠȡȓıȠȣȝİ IJȪʌȠȣȢ įİįȠȝȑȞȦȞ IJȦȞ ȠʌȠȓȦȞ ȠȚ IJȚȝȑȢ ʌİȡȚȠȡȓȗȠȞIJĮȚ ıİ ıȣȖțİțȡȚȝȑȞİȢ ȣʌȠʌİȡȚȠȤȑȢ ĮʌȜȫȞ Ȓ ȠȡȚȗȠȝȑȞȦȞ IJȪʌȦȞ. īȚĮ ʌĮȡȐįİȚȖȝĮ:


46

ǹȈȀǾȈǾ 8

CapitalLetter = 'A' .. 'Z'; ȅȡȓȗİȚ ȝȓĮ ȣʌȠʌİȡȚȠȤȒ IJȠȣ IJȪʌȠȣ ȤĮȡĮțIJȒȡĮ (Char), Ș ȠʌȠȓĮ ĮȞIJȚıIJȠȚȤİȓ ıIJĮ țİijĮȜĮȓĮ ȖȡȐȝȝĮIJĮ IJȠȣ ȜĮIJȚȞȚțȠȪ ĮȜijĮȕȒIJȠȣ.

Ǻathmos = 0 .. 10; ȅȡȓȗİȚ ȝȓĮ ȣʌȠʌİȡȚȠȤȒ IJȠȣ ĮțİȡĮȓȠȣ IJȪʌȠȣ (Integer), Ș ȠʌȠȓĮ ĮȞIJȚıIJȠȚȤİȓ ıIJȘȞ ȕĮșȝȠȜȠȖȓĮ İȞȩȢ ıʌȠȣįĮıIJȒ.

WorkingDay = Monday .. Friday ȅȡȓȗİȚ ȝȓĮ ȣʌȠʌİȡȚȠȤȒ IJȠȣ IJȪʌȠȣ Weekday, ʌȠȣ ȠȡȓıĮȝİ ıIJȘȞ ʌĮȡȐȖȡĮijȠ 8.2, Ș ȠʌȠȓĮ ĮȞIJȚıIJȠȚȤİȓ ıIJȚȢ İȡȖȐıȚȝİȢ ȘȝȑȡİȢ IJȘȢ İȕįȠȝȐįĮȢ. ȅȚ ʌĮȡĮʌȐȞȦ įȘȜȫıİȚȢ ȠȡȓȗȠȣȞ ȞȑȠȣȢ IJȪʌȠȣȢ įİįȠȝȑȞȦȞ. ĬĮ ʌȡȑʌİȚ İʌȠȝȑȞȦȢ ȞĮ ȠȡȓıȠȣȝİ țĮȚ IJȚȢ ĮȞIJȓıIJȠȚȤİȢ ȝİIJĮȕȜȘIJȑȢ ıIJȠ IJȝȒȝĮ Var IJȠȣ ʌȡȠȖȡȐȝȝĮIJȩȢ ȝĮȢ. ǼȚįȚțȐ ȖȚĮ IJȠȣȢ IJȪʌȠȣȢ ȣʌȠʌİȡȚȠȤȒȢ, İȓȞĮȚ įȣȞĮIJȒ Ș įȒȜȦıȘ IJȘȢ ȣʌȠʌİȡȚȠȤȒȢ IJĮȣIJȩȤȡȠȞĮ ȝİ IJȘȞ įȒȜȦıȘ IJȘȢ ȝİIJĮȕȜȘIJȒȢ (ĮʌȠijİȪȖȠȞIJĮȢ IJȠȞ ȠȡȚıȝȩ ıIJȠ IJȝȒȝĮ Type IJȠȣ ʌȡȠȖȡȐȝȝĮIJȠȢ). ȆĮȡȐįİȚȖȝĮ: Var x : 0 .. 10; 8.4 ȈȪȞȠȜĮ Ȃİ IJȘȞ ʌĮȡĮțȐIJȦ įȒȜȦıȘ: Type ȩȞȠȝĮ_IJȪʌȠȣ_ıȣȞȩȜȠȣ = Set of

IJȪʌȠȢ_įİįȠȝȑȞȦȞ;

ȝʌȠȡȠȪȝİ ȞĮ ȠȡȓıȠȣȝİ ȑȞĮȞ IJȪʌȠ įİįȠȝȑȞȦȞ Ƞ ȠʌȠȓȠȢ ʌĮȡȚıIJȐȞİȚ ıȪȞȠȜȠ. ȍȢ IJȪʌȠ įİįȠȝȑȞȦȞ ıIJȘȞ įȒȜȦıȘ ȝʌȠȡȠȪȝİ ȞĮ ȤȡȘıȚȝȠʌȠȚȒıȠȣȝİ ĮʌȜȩ Ȓ ȠȡȚȗȩȝİȞȠ IJȪʌȠ. Ǿ Pascal ʌİȡȚȠȡȓȗİȚ IJȠ ȝȑȖȚıIJȠ ĮȡȚșȝȩ IJȦȞ ȝİȜȫȞ İȞȩȢ ıȣȞȩȜȠȣ ıİ 256, ȑIJıȚ įİȞ ȝʌȠȡȠȪȝİ ȞĮ ȤȡȘıȚȝȠʌȠȚȒıȠȣȝİ ȦȢ IJȪʌȠ įİįȠȝȑȞȦȞ IJȠȣ ıȣȞȩȜȠȣ IJȠȞ IJȪʌȠ Integer. ǼʌȓıȘȢ įİȞ ȝʌȠȡȠȪȝİ ȞĮ ȤȡȘıȚȝȠʌȠȚȒıȠȣȝİ IJȠȞ IJȪʌȠ Real, İʌİȚįȒ ȠȚ IJȚȝȑȢ IJȠȣ įİȞ İȓȞĮȚ ʌİʌİȡĮıȝȑȞİȢ. ȆĮȡĮįİȓȖȝĮIJĮ: Type DigitSet = Set of 0..9; Letter = 'A'..'Z'; SetOfLetter = Set of Letter ; īȚĮ IJȘȞ ĮʌȩįȠıȘ IJȚȝȫȞ ıİ ıȪȞȠȜĮ ʌĮȡĮșȑIJȠȣȝİ IJȚȢ IJȚȝȑȢ IJȠȣ ıȣȞȩȜȠȣ ȝȑıĮ ıİ ȠȡșȠȖȫȞȚİȢ ĮȖțȪȜİȢ, ȤȦȡȚıȝȑȞİȢ ȝİ țȩȝȝĮIJĮ. ȆĮȡȐįİȚȖȝĮ: Program Test; Type IntegerSet = Set of 1..256; Letter = 'A'..'Z'; SetOfLetter = Set of Letter;


ȅȡȚȗȩȝİȞȠȚ ȉȪʌȠȚ ǻİįȠȝȑȞȦȞ

47

Var x : IntegerSet; y,z : SetOfLetter; Begin x:= [11,122,31,4,56,12]; y:= ['A','D', 'F']; z := [ ]; {țİȞȩ ıȪȞȠȜȠ} End. Ǿ İțIJȑȜİıȘ ʌȡȐȟİȦȞ țĮȚ ıȣıȤİIJȚıȝȫȞ ȝİIJĮȟȪ ıȣȞȩȜȦȞ ȖȓȞİIJĮȚ ȝİ IJȠȣȢ ʌĮȡĮțȐIJȦ IJİȜİıIJȑȢ: +

DzȞȦıȘ ıȣȞȩȜȦȞ

ʌ.Ȥ. [1,3,5]+[4,6]

o [1,3,5,4,6]

*

ȉȠȝȒ ıȣȞȩȜȦȞ

ʌ.Ȥ. [1,3,5]*[3,6]

o [3]

-

ǻȚĮijȠȡȐ ıȣȞȩȜȦȞ

ʌ.Ȥ. [1,3,5] - [3]

o [1,5]

=

ǿıȩIJȘIJĮ ıȣȞȩȜȦȞ

ʌ.Ȥ. [1,3] = [1,3,5]

o False

<>

ǹȞȚıȩIJȘIJĮ ıȣȞȩȜȦȞ

ʌ.Ȥ. [11,23] <> [1,3,5] o True

<=

ȊʌȠıȪȞȠȜȠ

ʌ.Ȥ. [1,3] <= [1,3,5]

o True

>=

ȊʌİȡıȪȞȠȜȠ

ʌ.Ȥ. [1,3] >= [1,3,5]

o False

IN

ȂȑȜȠȢ ıȣȞȩȜȠȣ

ʌ.Ȥ. 3 in [1,3,5]

o True

8.5 ǹıțȒıİȚȢ DZıțȘıȘ 8.1 ȃĮ ȖȡĮijİȓ ʌȡȩȖȡĮȝȝĮ, ex81.pas, IJȠ ȠʌȠȓȠ ȞĮ įȚĮȕȐȗİȚ Įʌȩ IJȠ ʌȜȘțIJȡȠȜȩȖȚȠ IJȘȞ ȦȡȚĮȓĮ ĮʌȠȗȘȝȓȦıȘ țĮșȫȢ țĮȚ IJȚȢ ȫȡİȢ İȡȖĮıȓĮȢ (ĮțȑȡĮȚȠȢ) ȖȚĮ țȐșİ ȝȑȡĮ IJȘȢ İȕįȠȝȐįĮȢ țĮȚ ȞĮ ȣʌȠȜȠȖȓȗİȚ IJȠȞ İȕįȠȝĮįȚĮȓȠ ȝȚıșȩ İȞȩȢ ȣʌĮȜȜȒȜȠȣ. ȁȐȕİIJİ ȣʌȩȥȘ ȩIJȚ IJȠ ȘȝİȡȠȝȓıșȚȠ İȓȞĮȚ ĮȣȟȘȝȑȞȠ țĮIJȐ ȝȚıȩ IJȠ ȈȐȕȕĮIJȠ, İȞȫ IJȘȞ ȀȣȡȚĮțȒ İȓȞĮȚ įȚʌȜȩ. ȈIJȠ ʌȡȩȖȡĮȝȝĮ ʌȡȑʌİȚ ȞĮ ȠȡȓȗİIJĮȚ, ȖȚĮ IJȚȢ ȝȑȡİȢ IJȘȢ İȕįȠȝȐįĮȢ, ȑȞĮȢ IJȪʌȠȢ ıĮȞ IJȠȞ ʌĮȡĮțȐIJȦ: Weekday = (Sun,Mon,Tue,Wed,Thu,Fri,Sat); DZıțȘıȘ 8.2 ȃĮ ȖȡĮijİȓ ʌȡȩȖȡĮȝȝĮ, ex82.pas, ıIJȠ ȠʌȠȓȠ ȞĮ ȠȡȓȗȠȞIJĮȚ ʌȑȞIJİ ȝİIJĮȕȜȘIJȑȢ ıIJȚȢ ȠʌȠȓİȢ ȞĮ ȝʌȠȡȠȪȝİ ȞĮ ĮʌȠșȘțİȪıȠȣȝİ IJȘȞ ȕĮșȝȠȜȠȖȓĮ ʌȑȞIJİ ıʌȠȣįĮıIJȫȞ ıİ ȑȞĮ ȝȐșȘȝĮ. Ǿ ȕĮșȝȠȜȠȖȓĮ IJȦȞ ıʌȠȣįĮıIJȫȞ ʌȡȑʌİȚ ȞĮ İȓȞĮȚ ȣʌȠʌİȡȚȠȤȒ ĮțİȡĮȓȦȞ ȝİ IJȚȝȑȢ Įʌȩ 1 ȑȦȢ 10. ȉȠ ʌȡȩȖȡĮȝȝĮ ȞĮ ȗȘIJȐ Įʌȩ IJȠȞ ȤȡȒıIJȘ ȞĮ İȚıȐȖİȚ IJȘȞ ȕĮșȝȠȜȠȖȓĮ țĮȚ ıIJȘȞ ıȣȞȑȤİȚĮ ȞĮ İțIJȣʌȫȞİȚ IJȠ ʌȠıȠıIJȩ İʌȚIJȣȤȓĮȢ ıIJȠ ȝȐșȘȝĮ. DZıțȘıȘ 8.3 ȃĮ ȖȡĮijİȓ ʌȡȩȖȡĮȝȝĮ, ex83.pas, IJȠ ȠʌȠȓȠ ȞĮ įȚĮȕȐȗİȚ Įʌȩ IJȠ ʌȜȘțIJȡȠȜȩȖȚȠ įȪȠ ʌȡȠIJȐıİȚȢ țĮșİȝȚȐ Įʌȩ IJȚȢ ȠʌȠȓİȢ IJİȜİȚȫȞİȚ ıİ ȝȓĮ IJİȜİȓĮ (.) țĮȚ ıIJȘȞ ıȣȞȑȤİȚĮ ȞĮ IJȣʌȫȞİȚ ȝȓĮ ȜȓıIJĮ ȝİ IJĮ ȖȡȐȝȝĮIJĮ ʌȠȣ İȝijĮȞȓȗȠȞIJĮȚ ıIJȘȞ ʌȡȫIJȘ ʌȡȩIJĮıȘ țĮȚ ȩȤȚ ıIJȘȞ įİȪIJİȡȘ.

ǹș. Ǽ. ȀȠȣIJıȠȞȚțȩȜĮȢ


48

ǹȈȀǾȈǾ 8

DZıțȘıȘ 8.4 ȃĮ ȖȡĮijİȓ ʌȡȩȖȡĮȝȝĮ, ex84.pas, ıIJȠ ȠʌȠȓȠ ȞĮ ȠȡȓȗȠȞIJĮȚ įȪȠ ıȪȞȠȜĮ ȝİ șİIJȚțȠȪȢ ȝȠȞȠȥȒijȚȠȣȢ Ȓ įȚȥȒijȚȠȣȢ ĮțİȡĮȓȠȣȢ ĮȡȚșȝȠȪȢ, ȞĮ ȗȘIJȐ Įʌȩ IJȠȞ ȤȡȒıIJȘ ȞĮ İȚıȐȖİȚ IJĮ ıIJȠȚȤİȓĮ IJȦȞ ıȣȞȩȜȦȞ țĮȚ ıIJȘȞ ıȣȞȑȤİȚĮ ȞĮ İțIJȣʌȫȞİȚ IJĮ ıIJȠȚȤİȓĮ IJȘȢ IJȠȝȒ IJȦȞ ıȣȞȩȜȦȞ. Ǿ İȚıĮȖȦȖȒ IJȦȞ ıIJȠȚȤİȓȦȞ ȖȚĮ IJȠ țȐșİ ıȪȞȠȜȠ ȞĮ ıIJĮȝĮIJȐ ȝİ IJȘȞ İȚıĮȖȦȖȒ Įʌȩ IJȠȞ ȤȡȒıIJȘ ĮȡȚșȝȠȪ Ƞ ȠʌȠȓȠȢ įİȞ İȓȞĮȚ ȝȠȞȠȥȒijȚȠȢ Ȓ įȚȥȒijȚȠȢ șİIJȚțȩȢ ĮțȑȡĮȚȠȢ. īȚĮ IJȘȞ İțIJȪʌȦıȘ IJȦȞ ıIJȠȚȤİȓȦȞ IJȘȢ IJȠȝȒȢ IJȦȞ ıȣȞȩȜȦȞ, ȤȡȘıȚȝȠʌȠȚȒıIJİ İȞIJȠȜȒ İʌĮȞȐȜȘȥȘȢ Ș ȠʌȠȓĮ İȟİIJȐȗİȚ ȖȚĮ ȩȜȠȣȢ IJȠȣȢ ȝȠȞȠȥȒijȚȠȣȢ țĮȚ įȚȥȒijȚȠȣȢ șİIJȚțȠȪȢ ĮțȑȡĮȚȠȢ ĮȞ ĮȞȒțȠȣȞ ıIJȘȞ IJȠȝȒ IJȦȞ ıȣȞȩȜȦȞ. ȈǾȂǼǿȍȈǼǿȈ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________


49

ǹȈȀǾȈǾ 9 ȆȓȞĮțİȢ 9.1 ǼȚıĮȖȦȖȒ ǼțIJȩȢ IJȦȞ ĮʌȜȫȞ IJȪʌȦȞ įİįȠȝȑȞȦȞ IJȠȣȢ ȠʌȠȓȠȣȢ ȑȤȠȣȝİ ȖȞȦȡȓıİȚ ıİ ʌȡȠȘȖȠȪȝİȞİȢ ĮıțȒıİȚȢ, ıIJȘȞ Pascal İȓȞĮȚ įȣȞĮIJȩȞ ȞĮ ȠȡȚıșȠȪȞ įȠȝȘȝȑȞȠȚ IJȪʌȠȚ įİįȠȝȑȞȦȞ. ȅȚ įȠȝȘȝȑȞȠȚ IJȪʌȠȚ įİįȠȝȑȞȦȞ İȓȞĮȚ ıȪȞșİIJȠȚ IJȪʌȠȚ IJȦȞ ȠʌȠȓȦȞ ȠȚ IJȚȝȑȢ ĮʌȠIJİȜȠȪȞIJĮȚ Įʌȩ IJȚȝȑȢ ĮʌȜȫȞ IJȪʌȦȞ. ȋĮȡĮțIJȘȡȚıIJȚțȩ ʌĮȡȐįİȚȖȝĮ įȠȝȘȝȑȞȠȣ IJȪʌȠȣ İȓȞĮȚ Ƞ ʌȓȞĮțĮȢ (array). ȅȚ ʌȓȞĮțİȢ ȝʌȠȡȠȪȞ ȞĮ İȓȞĮȚ ȝȠȞȠįȚȐıIJĮIJȠȚ, įȚįȚȐıIJĮIJȠȚ Ȓ țĮȚ ʌİȡȚııȠIJȑȡȦȞ įȚĮıIJȐıİȦȞ țĮȚ IJĮ ıIJȠȚȤİȓĮ IJȠȣȢ ʌȡȑʌİȚ ȠʌȦıįȒʌȠIJİ ȞĮ İȓȞĮȚ IJȠȣ ȚįȓȠȣ IJȪʌȠȣ (ʌ.Ȥ. ĮțȑȡĮȚȠȢ, ȤĮȡĮțIJȒȡĮȢ, ʌȡĮȖȝĮIJȚțȩȢ ĮȡȚșȝȩȢ ț.Ȝ.ʌ.), ȖȚĮ IJȠ ȜȩȖȠ ĮȣIJȩ ȠȚ ʌȓȞĮțİȢ ȜȑȖȠȞIJĮȚ ȠȝȠȖİȞİȓȢ įȠȝȑȢ įİįȠȝȑȞȦȞ. 9.2 ȅȡȚıȝȩȢ ȆȓȞĮțĮ īȚĮ IJȘȞ ȤȡȒıȘ İȞȩȢ ʌȓȞĮțĮ ıİ țȐʌȠȚȠ ʌȡȩȖȡĮȝȝĮ, İȓȞĮȚ ĮʌĮȡĮȓIJȘIJȠ ȞĮ ȠȡȚıșİȓ Ƞ IJȪʌȠȢ IJȠȣ ʌȓȞĮțĮ ıIJȠ IJȝȒȝĮ įȒȜȦıȘȢ IJȪʌȦȞ, IJȠ ȠʌȠȓȠ, ȩʌȦȢ ȒįȘ ȖȞȦȡȓȗȠȣȝİ, ȕȡȓıțİIJĮȚ ʌȡȚȞ Įʌȩ IJȠ IJȝȒȝĮ įȒȜȦıȘȢ ȝİIJĮȕȜȘIJȫȞ țĮȚ ȑȤİȚ IJȘȞ İʌȚțİijĮȜȓįĮ Type. ȅ ȠȡȚıȝȩȢ IJȠȣ IJȪʌȠȣ İȞȩȢ ȝȠȞȠįȚȐıIJĮIJȠȣ ʌȓȞĮțĮ ȖȓȞİIJĮȚ ȝİ IJȘȞ ʌĮȡĮțȐIJȦ įȒȜȦıȘ: Type ȩȞȠȝĮ_IJȪʌȠȣ=Array[țȐIJȦ_ȩȡȚȠ .. ʌȐȞȦ_ȩȡȚȠ] of IJȪʌȠȢ_ıIJȠȚȤİȓȦȞ; ȆĮȡĮįİȓȖȝĮIJĮ: Type Matrix1 = Array [1..10] of Integer; ȅȡȓȗİȚ ȑȞĮ IJȪʌȠ ȝȠȞȠįȚȐıIJĮIJȠȣ ʌȓȞĮțĮ ĮțİȡĮȓȦȞ ȝİ įİȓțIJȘ Įʌȩ 1 ȑȦȢ 10 Matrix2 = Array [1..20] of Char; ȅȡȓȗİȚ ȑȞĮ IJȪʌȠ ȝȠȞȠįȚȐıIJĮIJȠȣ ʌȓȞĮțĮ ȤĮȡĮțIJȒȡȦȞ ȝİ įİȓțIJȘ Įʌȩ 1 ȑȦȢ 20

10

20

Ȉİ ʌİȡȓʌIJȦıȘ ʌȠȣ șȑȜȠȣȝİ ȞĮ ȠȡȓıȠȣȝİ ʌȓȞĮțĮ ȝİ ʌİȡȚııȩIJİȡİȢ įȚĮıIJȐıİȚȢ, įȘȜȫȞȠȣȝİ IJĮ ʌȐȞȦ țĮȚ țȐIJȦ ȩȡȚĮ IJȦȞ įȚĮıIJȐıİȦȞ ȤȦȡȓȗȠȞIJĮȢ IJĮ ȝİIJĮȟȪ IJȠȣȢ ȝİ țȩȝȝĮ. ȆĮȡĮįİȓȖȝĮIJĮ: Type Matrix3 = Array [1..10,1..5] of Integer; ȅȡȓȗİȚ ȑȞĮ IJȪʌȠ įȚįȚȐıIJĮIJȠȣ ʌȓȞĮțĮ 10x5 ĮțİȡĮȓȦȞ ȝİ įİȓțIJİȢ Įʌȩ 1 ȑȦȢ 10 țĮȚ 1 ȑȦȢ 5. Matrix4 = Array [1..10,1..5,1..3] of Integer; ȅȡȓȗİȚ ȑȞĮ IJȪʌȠ IJȡȚįȚȐıIJĮIJȠȣ ʌȓȞĮțĮ 10x5x3 ĮțİȡĮȓȦȞ ȝİ įİȓțIJİȢ Įʌȩ 1 ȑȦȢ 10, 1 ȑȦȢ 5, țĮȚ 1 ȑȦȢ 3. ȅȚ ʌĮȡĮʌȐȞȦ įȘȜȫıİȚȢ, ȠȡȓȗȠȣȞ ȞȑȠȣȢ IJȪʌȠȣȢ įİįȠȝȑȞȦȞ. īȚĮ IJȘ ȤȡȒıȘ İȞȩȢ ʌȓȞĮțĮ ıİ țȐʌȠȚȠ ʌȡȩȖȡĮȝȝĮ șĮ ʌȡȑʌİȚ ȞĮ įȘȜȦșİȓ İʌȚʌȜȑȠȞ țĮȚ ȝİIJĮȕȜȘIJȒ IJȪʌȠȣ ʌȓȞĮțĮ. ĬĮ ȝʌȠȡȠȪıĮȝİ İʌȓıȘȢ, ȞĮ įȘȜȫıȠȣȝİ ȩIJȚ ȝȚĮ ȝİIJĮȕȜȘIJȒ İȓȞĮȚ IJȪʌȠȣ ʌȓȞĮțĮ, IJĮȣIJȩȤȡȠȞĮ ȝİ IJȘȞ įȒȜȦıȘ IJȘȢ ȝİIJĮȕȜȘIJȒȢ ıIJȠ IJȝȒȝĮ Var (ĮʌȠijİȪȖȠȞIJĮȢ ȑIJıȚ IJȠȞ ȠȡȚıȝȩ ıIJȠ IJȝȒȝĮ Type IJȠȣ ʌȡȠȖȡȐȝȝĮIJȠȢ).


50

ǹȈȀǾȈǾ 9

ȆĮȡȐįİȚȖȝĮ: Program Pinakas; Type {ǹȡȤȒ IJȝȒȝĮIJȠȢ Type} matrix=Array [1..3] of Integer; {ȅȡȚıȝȩȢ IJȪʌȠȣ ʌȓȞĮțĮ} Var m : matrix ; {ǻȒȜȦıȘ ȝİIJĮȕȜȘIJȒȢ ʌȓȞĮțĮ} Begin m[1] := 5; {ǹʌȩįȠıȘ IJȚȝȒȢ ıIJȠ ıIJȠȚȤİȓȠ 1} m[2] := 10; {ǹʌȩįȠıȘ IJȚȝȒȢ ıIJȠ ıIJȠȚȤİȓȠ 2} m[3] := 15; {ǹʌȩįȠıȘ IJȚȝȒȢ ıIJȠ ıIJȠȚȤİȓȠ 3} Writeln('ȉĮ ıIJȠȚȤİȓĮ IJȠȣ ʌȓȞĮțĮ İȓȞĮȚ'); Writeln('ȉȠ ıIJȠȚȤİȓȠ 1 İȓȞĮȚ: ', m[1]); Writeln('ȉȠ ıIJȠȚȤİȓȠ 2 İȓȞĮȚ: ', m[2]); Writeln('ȉȠ ıIJȠȚȤİȓȠ 3 İȓȞĮȚ: ', m[3]); End. ǵʌȦȢ ijĮȓȞİIJĮȚ Įʌȩ IJȠ ʌĮȡĮʌȐȞȦ ʌĮȡȐįİȚȖȝĮ, ȖȚĮ IJȘȞ ʌȡȩıȕĮıȘ ıİ țȐʌȠȚȠ ıIJȠȚȤİȓȠ IJȠȣ ʌȓȞĮțĮ (ȖȚĮ țĮIJĮȤȫȡȚıȘ Ȓ ĮȞȐȖȞȦıȘ IJȘȢ IJȚȝȒȢ) ȤȡȘıȚȝȠʌȠȚİȓIJĮȚ IJȠ ȩȞȠȝĮ IJȘȢ ȝİIJĮȕȜȘIJȒȢ ʌȓȞĮțĮ țĮȚ Ƞ įİȓțIJȘȢ IJȠȣ ıIJȠȚȤİȓȠȣ İȞIJȩȢ ĮȖțȣȜȫȞ (ıİ ʌİȡȓʌIJȦıȘ ʌȠȜȜȫȞ įȚĮıIJȐıİȦȞ ȠȚ įİȓțIJİȢ ȤȦȡȓȗȠȞIJĮȚ ȝİ țȩȝȝĮIJĮ). 9.3 ȋȡȒıȘ ȆȚȞȐțȦȞ ıİ ȆȡȠȖȡȐȝȝĮIJĮ ȈȣȤȞȐ ȣʌȐȡȤİȚ Ș ĮȞȐȖțȘ ȤȡȒıȘȢ ʌȚȞȐțȦȞ ıİ ʌȡȠȖȡȐȝȝĮIJĮ ȖȚĮ IJȘȞ ĮʌȠșȒțİȣıȘ țĮȚ įȚĮȤİȓȡȚıȘ ȠȝȠİȚįȫȞ ıIJȠȚȤİȓȦȞ. ȁȩȖȦ IJȘȢ ijȪıȘȢ IJȦȞ ʌȚȞȐțȦȞ (ȩʌȠȣ Ș įȚȐIJĮȟȘ IJȦȞ ıIJȠȚȤİȓȦȞ ȖȓȞİIJĮȚ ȝİ IJȘȞ ȤȡȒıȘ įİȚțIJȫȞ), İȓȞĮȚ İʌȩȝİȞȠ Ș įȚĮȤİȓȡȚıȘ IJȠȣȢ ȞĮ ȖȓȞİIJĮȚ ȝİ İȞIJȠȜȑȢ İʌĮȞȐȜȘȥȘȢ. ȈIJȠ ʌĮȡĮțȐIJȦ ʌȡȩȖȡĮȝȝĮ ȠȡȓȗİIJĮȚ ȑȞĮȢ ʌȓȞĮțĮȢ 5x4 ʌȡĮȖȝĮIJȚțȫȞ ĮȡȚșȝȫȞ, ȗȘIJİȓIJĮȚ Įʌȩ IJȠȞ ȤȡȒıIJȘ ȞĮ İȚıȐȖİȚ IJȚȢ IJȚȝȑȢ IJȦȞ ıIJȠȚȤİȓȦȞ IJȠȣ ʌȓȞĮțĮ țĮȚ ıIJȘ ıȣȞȑȤİȚĮ İțIJȣʌȫȞȠȞIJĮȚ IJĮ ıIJȠȚȤİȓĮ IJȠȣ ʌȓȞĮțĮ ıIJȘȞ ȠșȩȞȘ. Program Pinakas1; Type matrix = Array [1..5,1..4] of Real; Var m :matrix; i,j :Integer; Begin {ǼȚıĮȖȦȖȒ IJȦȞ ıIJȠȚȤİȓȦȞ IJȠȣ ʌȓȞĮțĮ Įʌȩ IJȠȞ ȤȡȒıIJȘ} For i:= 1 t o 5 do For j:= 1 to 4 do Begin Write('ǻȫıİ IJȠ ıIJȠȚȤİȓȠ ',i,' ',j, ' IJȠȣ ʌȓȞĮțĮ '); Readln(m[i,j]); End; {ǼțIJȪʌȦıȘ IJȦȞ ıIJȠȚȤİȓȦȞ IJȠȣ ʌȓȞĮțĮ ıIJȘȞ ȠșȩȞȘ } Writeln('ȉĮ ıIJȠȚȤİȓĮ IJȠȣ ʌȓȞĮțĮ İȓȞĮȚ:'); For i:= 1 t o 5 do Begin For j:= 1 to 4 do Write(m[i,j]:6:1); Writeln; End; End.


ȆȓȞĮțİȢ

51

ȅȚ ʌȡȐȟİȚȢ ȝİ IJĮ ıIJȠȚȤİȓĮ IJȠȣ ʌȓȞĮțĮ ȖȓȞȠȞIJĮȚ ȩʌȦȢ țĮȚ ȝİ IJȚȢ ȣʌȩȜȠȚʌİȢ ȝİIJĮȕȜȘIJȑȢ ȝİ IJȘȞ ʌȡȠȨʌȩșİıȘ ȩIJȚ ȤİȚȡȓȗȠȞIJĮȚ ıȦıIJȐ ȠȚ įİȓțIJİȢ IJȦȞ ıIJȠȚȤİȓȦȞ. ȆȡȑʌİȚ ȞĮ İȓȝĮıIJİ ȚįȚĮȓIJİȡĮ ʌȡȠıİțIJȚțȠȓ ȝİ IJȠȣȢ įİȓțIJİȢ IJȦȞ ıIJȠȚȤİȓȦȞ IJȠȣ ʌȓȞĮțĮ. ǹȣIJȠȓ ʌȡȑʌİȚ ȞĮ İȓȞĮȚ ĮțȑȡĮȚȠȚ țĮȚ ȞĮ ʌĮȓȡȞȠȣȞ IJȚȝȑȢ İȞIJȩȢ IJȘȢ ʌİȡȚȠȤȒȢ (ȐȞȦ țĮȚ țȐIJȦ ȩȡȚȠ) IJȠ ȠʌȠȓȠ ȠȡȓȗİIJĮȚ ıIJȘȞ įȒȜȦıȘ IJȠȣ IJȪʌȠȣ IJȠȣ ʌȓȞĮțĮ. ȍȢ ıȣȞȑȤİȚĮ ıIJȠ ʌȡȠȘȖȠȪȝİȞȠ ʌĮȡȐįİȚȖȝĮ, ȝʌȠȡȠȪȝİ ȞĮ ʌȡȠıșȑıȠȣȝİ ıIJȠ IJȑȜȠȢ, ȝİIJȐ IJȘȞ İțIJȪʌȦıȘ IJȠȣ ʌȓȞĮțĮ, IJȠ ʌĮȡĮțȐIJȦ IJȝȒȝĮ IJȠ ȠʌȠȓȠ ȣʌȠȜȠȖȓȗİȚ IJȠ ȐșȡȠȚıȝĮ IJȘȢ țȐșİ ȖȡĮȝȝȒȢ IJȠȣ ʌȓȞĮțĮ. {ǼțIJȪʌȦıȘ IJȠȣ ĮșȡȠȓıȝĮIJȠȢ IJȘȢ țȐșİ ȖȡĮȝȝȒȢ} For i:= 1 t o 5 do Begin Write('To ȐșȡȠȚıȝĮ IJȘȢ ȖȡĮȝȝȒȢ ', i,' İȓȞĮȚ '); Writeln(m[i,1]+m[i,2] + m[i,3] + m[i,4]:10:1); Writeln; End; 9.4 ǹıțȒıİȚȢ DZıțȘıȘ 9.1 ȃĮ ȖȡĮijİȓ ʌȡȩȖȡĮȝȝĮ, ex91.pas, ıIJȠ ȠʌȠȓȠ ȞĮ ȠȡȓȗİIJĮȚ ȑȞĮȢ ʌȓȞĮțĮȢ ĮțİȡĮȓȦȞ ĮȡȚșȝȫȞ 4x6. ȉȠ ʌȡȩȖȡĮȝȝĮ ȞĮ ȗȘIJȐ Įʌȩ IJȠȞ ȤȡȒıIJȘ ȞĮ İȚıȐȖİȚ IJĮ ıIJȠȚȤİȓĮ IJȠȣ ʌȓȞĮțĮ țĮȚ ıIJȘȞ ıȣȞȑȤİȚĮ ȞĮ İțIJȣʌȫȞİȚ IJȠȞ ʌȓȞĮțĮ ıIJȘȞ ȠșȩȞȘ, ıİ 4 ȖȡĮȝȝȑȢ țĮȚ 6 ıIJȒȜİȢ. DZıțȘıȘ 9.2 ȃĮ IJȡȠʌȠʌȠȚȒıİIJİ IJȠ ʌĮȡĮʌȐȞȦ ʌȡȩȖȡĮȝȝĮ ex91.pas (ĮʌȠșȘțİȪıIJİ IJȠ ȦȢ ex92.pas) ȫıIJİ ȞĮ ȣʌȠȜȠȖȓȗİȚ țĮȚ ȞĮ İțIJȣʌȫȞİȚ İʌȚʌȜȑȠȞ IJȠ ʌȜȒșȠȢ IJȦȞ șİIJȚțȫȞ ıIJȠȚȤİȓȦȞ IJȠȣ ʌȓȞĮțĮ, IJȠ ʌȜȒșȠȢ IJȦȞ ĮȡȞȘIJȚțȫȞ ıIJȠȚȤİȓȦȞ IJȠȣ ʌȓȞĮțĮ țĮȚ IJȠȞ ȝȑıȠ ȩȡȠ IJȦȞ ıIJȠȚȤİȓȦȞ IJȠȣ ʌȓȞĮțĮ. DZıțȘıȘ 9.3 ȃĮ ȖȡĮijİȓ ʌȡȩȖȡĮȝȝĮ, ex93.pas, ıIJȠ ȠʌȠȓȠ ȞĮ ȠȡȓȗİIJĮȚ ȑȞĮȢ ʌȓȞĮțĮȢ ȤĮȡĮțIJȒȡȦȞ ȝİ įȚĮıIJȐıİȚȢ 8x8. ȈIJȘ ıȣȞȑȤİȚĮ įȫıIJİ IJȘȞ IJȚȝȒ ‘*’ ıIJĮ ıIJȠȚȤİȓĮ IJȘȢ țȪȡȚĮȢ țĮȚ įİȣIJİȡİȪȠȣıĮȢ įȚĮȖȦȞȓȠȣ IJȠȣ ʌȓȞĮțĮ țĮȚ IJȘȞ IJȚȝȒ ‘ ‘ (țİȞȩȢ ȤĮȡĮțIJȒȡĮȢ) ıIJĮ ȣʌȩȜȠȚʌĮ ıIJȠȚȤİȓĮ IJȠȣ ʌȓȞĮțĮ. ȉȑȜȠȢ İțIJȣʌȫıIJİ IJȠȞ ʌȓȞĮțĮ ıIJȘȞ ȠșȩȞȘ. DZıțȘıȘ 9.4 ȉȡȠʌȠʌȠȚȒıIJİ IJȠ ʌĮȡĮʌȐȞȦ ʌȡȩȖȡĮȝȝĮ țĮȚ ĮʌȠșȘțİȪıIJİ IJȠ ȝİ IJȠ ȩȞȠȝĮ ex94.pas, ȫıIJİ IJȠ IJİȜȚțȩ ĮʌȠIJȑȜİıȝĮ IJȘȢ İțIJȪʌȦıȘȢ ȞĮ İȓȞĮȚ IJȠ ʌĮȡĮțȐIJȦ ıȤȒȝĮ: ******** ****** **** ** ** **** ****** ********

ǹș. Ǽ. ȀȠȣIJıȠȞȚțȩȜĮȢ


52

ǹȈȀǾȈǾ 9

ȈǾȂǼǿȍȈǼǿȈ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________


53

ǹȈȀǾȈǾ 10 ǼȖȖȡĮijȑȢ 10.1 ǼȚıĮȖȦȖȒ ȈȣȤȞȐ ȣʌȐȡȤİȚ Ș ĮȞȐȖțȘ ȠȡȚıȝȠȪ ıȪȞșİIJȦȞ IJȪʌȦȞ įİįȠȝȑȞȦȞ ȠȚ ȠʌȠȓȠȚ ȞĮ ȠȝĮįȠʌȠȚȠȪȞ ĮȞȠȝȠȚȠȖİȞİȓȢ IJȪʌȠȣȢ ĮʌȜȠȪıIJİȡȦȞ įİįȠȝȑȞȦȞ. ǹȣIJȩ İʌȚIJȣȖȤȐȞİIJĮȚ ȤȡȘıȚȝȠʌȠȚȫȞIJĮȢ IJȠȞ ıȪȞșİIJȠ IJȪʌȠ IJȘȢ İȖȖȡĮijȒȢ (record). īȚĮ ʌĮȡȐįİȚȖȝĮ, ȝʌȠȡȠȪȝİ ȞĮ ȠȡȓıȠȣȝİ ȑȞĮ ıȪȞșİIJȠ IJȪʌȠ įİįȠȝȑȞȦȞ Ƞ ȠʌȠȓȠȢ ĮȞĮʌĮȡȚıIJȐ IJĮ ıIJȠȚȤİȓĮ İȞȩȢ ıʌȠȣįĮıIJȒ: ȩȞȠȝĮ, İʌȓșİIJȠ, ȩȞȠȝĮ ʌĮIJȡȩȢ, İȟȐȝȘȞȠ, țȦįȚțȩ ĮȡȚșȝȩ, ȑIJȠȢ ȖȑȞȞȘıȘȢ, įȚİȪșȣȞıȘ ț.Ȝ.ʌ. ȀĮșȑȞĮ Įʌȩ IJĮ ıIJȠȚȤİȓĮ ĮȣIJȐ ȠȞȠȝȐȗİIJĮȚ ʌİįȓȠ (field) IJȘȢ İȖȖȡĮijȒȢ. ȂİȡȚțȐ Įʌȩ IJĮ ʌİįȓĮ șĮ ȝʌȠȡȠȪıĮȞ țȚ ĮȣIJȐ ȝİ IJȘ ıİȚȡȐ IJȠȣȢ ȞĮ İȓȞĮȚ İȖȖȡĮijȑȢ, ȩʌȦȢ ȖȚĮ ʌĮȡȐįİȚȖȝĮ Ș įȚİȪșȣȞıȘ. 10.2 ȅȡȚıȝȩȢ ǼȖȖȡĮijȒȢ ȅ ȠȡȚıȝȩȢ İȞȩȢ IJȪʌȠȣ İȖȖȡĮijȒȢ ȖȓȞİIJĮȚ ȝİ IJȘȞ ʌĮȡĮțȐIJȦ įȒȜȦıȘ: Type ȩȞȠȝĮ_IJȪʌȠȣ_İȖȖȡĮijȒȢ = Record ȩȞȠȝĮ_ʌİįȓȠȣ1 : IJȪʌȠȢ_ʌİįȓȠȣ1; ȩȞȠȝĮ_ʌİįȓȠȣ2 : IJȪʌȠȢ_ʌİįȓȠȣ2; ... ... ... ... ȩȞȠȝĮ_ʌİįȓȠȣn : IJȪʌȠȢ_ʌİįȓȠȣn; End; ȆĮȡȐįİȚȖȝĮ ȠȡȚıȝȠȪ İȞȩȢ IJȪʌȠȣ İȖȖȡĮijȒȢ Ș ȠʌȠȓĮ ĮȞĮʌĮȡȚıIJȐ IJĮ ıIJȠȚȤİȓĮ İȞȩȢ ıʌȠȣįĮıIJȒ İȓȞĮȚ: Type StudentData = Record FirstName : String[20]; {ȅȞȠȝĮ} LastName : String[20]; {ǼʌȫȞȣȝȠ} FatherName : String[20]; {ȅȞȠȝĮ ȆĮIJȡȩȢ} Examino : String[3]; {ǼȟȐȝȘȞȠ} StudentID : Integer; {ȀȦįȚțȩȢ ıʌȠȣįĮıIJȒ} BirthYear : Integer; {ǼIJȠȢ ȖȑȞȞȘıȘȢ} End; ȅ ȠȡȚıȝȩȢ İȞȩȢ IJȪʌȠȣ İȖȖȡĮijȒȢ, įİȞ İȓȞĮȚ ĮȡțİIJȩȢ ȖȚĮ IJȘ ȤȡȒıȘ İȖȖȡĮijȫȞ ıİ țȐʌȠȚȠ ʌȡȩȖȡĮȝȝĮ. ȆȡȑʌİȚ ȞĮ ȠȡȚıșȠȪȞ țĮȚ ȝİIJĮȕȜȘIJȑȢ ĮȣIJȠȪ IJȠȣ IJȪʌȠȣ, ȠȚ ȠʌȠȓİȢ įİıȝİȪȠȣȞ ȝȞȒȝȘ ȖȚĮ IJȘȞ ĮʌȠșȒțİȣıȘ IJȦȞ įİįȠȝȑȞȦȞ. DzIJıȚ ıĮȞ ıȣȞȑȤİȚĮ IJȠȣ ʌĮȡĮʌȐȞȦ ʌĮȡĮįİȓȖȝĮIJȠȢ, İȐȞ șȑȜȠȣȝİ ȞĮ ȤȡȘıȚȝȠʌȠȚȒıȠȣȝİ įȪȠ ȝİIJĮȕȜȘIJȑȢ ȠȚ ȠʌȠȓİȢ ȞĮ ȤȡȘıȚȝȠʌȠȚȘșȠȪȞ ȖȚĮ IJȘȞ ĮʌȠșȒțİȣıȘ IJȦȞ ıIJȠȚȤİȓȦȞ įȪȠ ıʌȠȣįĮıIJȫȞ, ʌȡȑʌİȚ ȞĮ įȘȜȫıȠȣȝİ ıIJȠ IJȝȒȝĮ Var IJȠȣ ʌȡȠȖȡȐȝȝĮIJȠȢ: Var x1,x2 : StudentData; ȑIJıȚ ȠȚ ȝİIJĮȕȜȘIJȑȢ x1 țĮȚ x2 ĮȞIJȚıIJȠȚȤȠȪȞ ıİ įȪȠ İȖȖȡĮijȑȢ ȝİ ıIJȠȚȤİȓĮ ıʌȠȣįĮıIJȫȞ. ĬĮ ȝʌȠȡȠȪıĮȝİ İʌȓıȘȢ, ȞĮ įȘȜȫıȠȣȝİ ȩIJȚ ȝȚĮ ȝİIJĮȕȜȘIJȒ İȓȞĮȚ IJȪʌȠȣ İȖȖȡĮijȒȢ, IJĮȣIJȩȤȡȠȞĮ ȝİ IJȘȞ įȒȜȦıȘ IJȘȢ ȝİIJĮȕȜȘIJȒȢ ıIJȠ IJȝȒȝĮ Var (ĮʌȠijİȪȖȠȞIJĮȢ ȑIJıȚ IJȠȞ ȠȡȚıȝȩ ıIJȠ IJȝȒȝĮ Type IJȠȣ ʌȡȠȖȡȐȝȝĮIJȠȢ). 10.3 ǼʌİȟİȡȖĮıȓĮ ǼȖȖȡĮijȫȞ īȚĮ IJȘȞ İʌİȟİȡȖĮıȓĮ IJȦȞ IJȚȝȫȞ ʌȠȣ ʌİȡȚȑȤȠȞIJĮȚ ıIJĮ ʌİįȓĮ ȝȚĮȢ İȖȖȡĮijȒȢ ȤȡȘıȚȝȠʌȠȚȠȪȞIJĮȚ țȣȡȓȦȢ įȪȠ ȝȑșȠįȠȚ.


54

ǹȈȀǾȈǾ 10

ȈȪȝijȦȞĮ ȝİ IJȘȞ ʌȡȫIJȘ ȝȑșȠįȠ, ȖȚĮ ȞĮ ĮȞĮijİȡșȠȪȝİ ıİ ȑȞĮ ıȣȖțİțȡȚȝȑȞȠ ʌİįȓȠ ȝȚĮȢ İȖȖȡĮijȒȢ ȖȡȐijȠȣȝİ IJȠ ȩȞȠȝĮ IJȘȢ İȖȖȡĮijȒȢ, ȝİIJȐ ȝȓĮ IJİȜİȓĮ '.' țĮȚ ıIJȘ ıȣȞȑȤİȚĮ IJȠ ȩȞȠȝĮ IJȠȣ ʌİįȓȠȣ. ȈIJȠ ʌĮȡĮțȐIJȦ ʌĮȡȐįİȚȖȝĮ ijĮȓȞİIJĮȚ ʌȫȢ țĮIJĮȤȦȡȠȪȝİ IJȚȝȑȢ ıIJĮ ʌİįȓĮ IJȦȞ İȖȖȡĮijȫȞ x1 țĮȚ x2 ʌȠȣ ȠȡȓıĮȝİ ʌĮȡĮʌȐȞȦ: x1.FirstName := 'ȃȓțȠȢ'; x1.LastName := 'ǹʌȠıIJȩȜȠȣ'; x1.FatherName := 'īİȫȡȖȚȠȢ'; x1.Examino := 'A'; x1.StudentID := 2345; x1.BirthYear := 1982;

x2.FirstName x2.LastName x2.FatherName x2.Examino x2.StudentID x2.BirthYear

:= := := := := :=

'ǻȘȝȠıșȑȞȘȢ'; 'īİȦȡȖȓȠȣ'; 'ȃȚțȩȜĮȠȢ'; 'B'; 3001; 1979;

ȈȪȝijȦȞĮ ȝİ IJȘȞ įİȪIJİȡȘ ȝȑșȠįȠ, ȖȚĮ IJȘȞ ĮʌȜȠȪıIJİȣıȘ IJȘȢ ĮȞĮijȠȡȐȢ ıIJȠ ʌİįȓĮ ȝȚĮȢ İȖȖȡĮijȒȢ, ȝʌȠȡİȓ ȞĮ ȤȡȘıȚȝȠʌȠȚȘșİȓ Ș İȞIJȠȜȒ With. Ȃİ IJȘȞ ȤȡȒıȘ IJȘȢ İȞIJȠȜȒȢ ĮȣIJȒȢ ȝʌȠȡȠȪȝİ ȞĮ ĮȞĮijİȡȩȝĮıIJİ ȐȝİıĮ ıIJĮ ʌİįȓĮ țȐʌȠȚĮȢ İȖȖȡĮijȒȢ. ȉȠ ʌĮȡĮʌȐȞȦ ʌĮȡȐįİȚȖȝĮ ȖȓȞİIJĮȚ: With x1 do Begin FirstName := 'ȃȓțȠȢ'; LastName := 'ǹʌȠıIJȩȜȠȣ'; FatherName := 'īİȫȡȖȚȠȢ'; Examino := 'A'; StudentID := 2345; BirthYear := 1982; End;

With x2 do Begin FirstName LastName FatherName Examino StudentID BirthYear End;

:= := := := := :=

'ǻȘȝȠıșȑȞȘȢ'; 'īİȦȡȖȓȠȣ'; 'ȃȚțȩȜĮȠȢ'; 'B'; 3001; 1979;

īȚĮ IJȘȞ İȚıĮȖȦȖȒ IJȚȝȫȞ, ıIJĮ ʌİįȓĮ ȝȚĮȢ İȖȖȡĮijȒȢ, Įʌȩ IJȠ ʌȜȘțIJȡȠȜȩȖȚȠ, țĮșȫȢ țĮȚ ȖȚĮ IJȘȞ İțIJȪʌȦıȘ IJȦȞ IJȚȝȫȞ IJȦȞ ʌİįȓȦȞ ıIJȘȞ ȠșȩȞȘ, ȝʌȠȡȠȪȝİ ȞĮ ȤȡȘıȚȝȠʌȠȚȒıȠȣȝİ IJȚȢ İȞIJȠȜȑȢ Read - Readln țĮȚ Write - Writeln ĮȞIJȓıIJȠȚȤĮ, ȩʌȦȢ ijĮȓȞİIJĮȚ ʌĮȡĮțȐIJȦ: {ǼȚıĮȖȦȖȒ IJȚȝȫȞ Įʌȩ IJȠ ʌȜȘțIJȡȠȜȩȖȚȠ} Write ('ǻȫıİ ȩȞȠȝĮ : '); Readln(x1.FirstName); Write ('ǻȫıİ İʌȓșİIJȠ : '); Readln(x1.LastName); Write ('ǻȫıİ ȩȞȠȝĮ ʌĮIJȡȩȢ : '); Readln(x1.FatherName); Write ('ǻȫıİ İȟȐȝȘȞȠ : '); Readln(x1.Examino);


ǼȖȖȡĮijȑȢ

55

Write ('ǻȫıİ țȦįȚțȩ ıʌȠȣįĮıIJȒ : '); Readln(StudentID); Write ('ǻȫıİ ȑIJȠȢ ȖȑȞȞȘıȘȢ : '); Readln(x1.BirthYear); {ǼțIJȪʌȦıȘ ıIJȘȞ ȠșȩȞȘ} Write ('ȅȞȠȝĮ : '); Writeln(x1.FirstName); Write ('ǼʌȓșİIJȠ : '); Writeln(x1.LastName); Write ('ȅȞȠȝĮ ʌĮIJȡȩȢ : '); Writeln(x1.FatherName); Write ('ǼȟȐȝȘȞȠ : '); Writeln(x1.Examino); Write ('ȀȦįȚțȩȢ ıʌȠȣįĮıIJȒ : '); Writeln(StudentID); Write ('ǼIJȠȢ ȖȑȞȞȘıȘȢ : '); Writeln(x1.BirthYear); 10.4 ȆȓȞĮțİȢ ǼȖȖȡĮijȫȞ Ȉİ ʌİȡȚʌIJȫıİȚȢ ȩʌȠȣ ĮʌĮȚIJİȓIJĮȚ Ș ȤȡȒıȘ ʌȠȜȜȫȞ İȖȖȡĮijȫȞ IJȠȣ ȓįȚȠȣ IJȪʌȠȣ, ȝʌȠȡȠȪȝİ ȞĮ ȤȡȘıȚȝȠʌȠȚȒıȠȣȝİ ʌȓȞĮțĮ ȑȖȖȡĮijȫȞ. ȆĮȡȐįİȚȖȝĮ: Type StudentData = Record FirstName : String[20]; {ȅȞȠȝĮ} LastName : String[20]; {ǼʌȫȞȣȝȠ} FatherName : String[20]; {ȅȞȠȝĮ ȆĮIJȡȩȢ} Examino : String[3]; {ǼȟȐȝȘȞȠ} StudentID : Integer {ȀȦįȚțȩȢ ıʌȠȣįĮıIJȒ} BirthYear : Integer {ǼIJȠȢ ȖȑȞȞȘıȘȢ} End; StudentArray = Array [1..20] of StudentData; Var Students:StudentArray; {ȂİIJĮȕȜȘIJȒ ʌȓȞĮțĮ ȝİ ıIJȠȚȤİȓĮ İȖȖȡĮijȑȢ} īȚĮ IJȘȞ ĮȞȐșİıȘ IJȚȝȫȞ ıİ ʌİįȓĮ İȖȖȡĮijȫȞ IJĮ ȠʌȠȓĮ İȓȞĮȚ ıIJȠȚȤİȓĮ İȞȩȢ ʌȓȞĮțĮ, ȤȡȘıȚȝȠʌȠȚȠȪȝİ IJȘȞ ȝİIJĮȕȜȘIJȒ ʌȓȞĮțĮ, IJȠȞ įİȓțIJȘ IJȠȣ ıIJȠȚȤİȓȠȣ țĮȚ IJȠ ȩȞȠȝĮ IJȠȣ ʌİįȓȠȣ IJȘȢ İȖȖȡĮijȒȢ: Students[1].FirstName := 'ȃȓțȠȢ'; Students[1].LastName := 'ǹʌȠıIJȩȜȠȣ'; Students[1].FatherName := 'īİȫȡȖȚȠȢ'; Students[1].Examino := 'ǹ'; Students[1].StudentID := 2345; Students[1].BirthYear := 1982; ȩʌȠȣ șȑIJȠȣȝİ IJȚȝȑȢ ıIJȘȞ İȖȖȡĮijȒ ʌȠȣ ȕȡȓıțİIJĮȚ ıIJȠ ʌȡȫIJȠ ıIJȠȚȤİȓȠ IJȠȣ ʌȓȞĮțĮ, Ȓ İȞĮȜȜĮțIJȚțȐ: With Students[1] do Begin FirstName := 'ȃȓțȠȢ'; LastName := 'ǹʌȠıIJȩȜȠȣ'; FatherName := 'īİȫȡȖȚȠȢ'; Examino := 'ǹ'; StudentID := 2345; BirthYear := 1982; End; ǹș. Ǽ. ȀȠȣIJıȠȞȚțȩȜĮȢ


56

ǹȈȀǾȈǾ 10

Ǿ İȓıȠįȠȢ Įʌȩ IJȠ ʌȜȘțIJȡȠȜȩȖȚȠ țĮȚ Ș İțIJȪʌȦıȘ ʌȚȞȐțȦȞ ȝİ İȖȖȡĮijȑȢ ȖȓȞİIJĮȚ ıȣȞȒșȦȢ ȝİ İȞIJȠȜȑȢ İʌĮȞȐȜȘȥȘȢ: ȆĮȡȐįİȚȖȝĮ: For i := 1 to 20 do Begin Writeln('******************************'); Writeln('ǼȚıĮȖȦȖȒ ıIJȠȚȤİȓȦȞ ıʌȠȣįĮıIJȒ ', i); Writeln('******************************') Write ('ǻȫıİ ȩȞȠȝĮ : '); Readln (Students[i].FirstName); Write ('ǻȫıİ İʌȓșİIJȠ : '); Readln (Students[i].LastName); Write ('ǻȫıİ ȩȞȠȝĮ ʌĮIJȡȩȢ : '); Readln (Students[i].FatherName); Write ('ǻȫıİ İȟȐȝȘȞȠ : '); Readln (Students[i].Examino); Write ('ǻȫıİ țȦįȚțȩ ıʌȠȣįĮıIJȒ : '); Readln (Students[i].StudentID); Write ('ǻȫıİ ȑIJȠȢ ȖȑȞȞȘıȘȢ : '); Readln (Students[i].BirthYear); End; 10.5 DzȞșİIJİȢ ǼȖȖȡĮijȑȢ ȉĮ ʌİįȓĮ İȖȖȡĮijȫȞ ȝʌȠȡȠȪȞ ȞĮ İȓȞĮȚ țĮȚ ĮȣIJȐ İȖȖȡĮijȑȢ (ȒįȘ ȠȡȚıȝȑȞİȢ). ȆĮȡȐįİȚȖȝĮ: Type BirthDate = Record Day : 1..31; Month : 1..12; Year : 1000..3000; End;

StudentData = Record FirstName LastName FatherName Examino StudentID Bdate End;

: : : : : :

String[20]; String[20]; String[20]; String[3]; Integer BirthDate

{ȅȞȠȝĮ} {ǼʌȫȞȣȝȠ} {ȅȞȠȝĮ ȆĮIJȡȩȢ} {ǼȟȐȝȘȞȠ} {ȀȦįȚțȩȢ ıʌȠȣįĮıIJȒ} {ǾȝİȡȠȝȘȞȓĮ ȖȑȞȞȘıȘȢ}

10.6 ǹıțȒıİȚȢ DZıțȘıȘ 10.1 ȃĮ ȖȡĮijİȓ ʌȡȩȖȡĮȝȝĮ, ex101.pas, ıIJȠ ȠʌȠȓȠ ȞĮ ȠȡȓıİIJİ İȖȖȡĮijȒ ȝİ ʌİįȓĮ IJĮ ıIJȠȚȤİȓĮ İȞȩȢ țĮȜĮșȠıijĮȚȡȚıIJȒ ʌȠȣ ijĮȓȞȠȞIJĮȚ ʌĮȡĮțȐIJȦ: ȅȞȠȝĮIJİʌȫȞȣȝȠ ǹȜijĮȡȚșȝȘIJȚțȩ 40 ȤĮȡĮțIJȒȡȦȞ ǶȥȠȢ ȆȡĮȖȝĮIJȚțȩȢ ȅȝȐįĮ ǹȜijĮȡȚșȝȘIJȚțȩ 40 ȤĮȡĮțIJȒȡȦȞ ǾȜȚțȓĮ ǹțȑȡĮȚȠȢ ǺȐȡȠȢ ȆȡĮȖȝĮIJȚțȩȢ ȈȣȝȝİIJȠȤȑȢ ıİ İșȞȚțȒ ǹțȑȡĮȚȠȢ


ǼȖȖȡĮijȑȢ

57

ȉȠ ʌȡȩȖȡĮȝȝĮ ȞĮ ȗȘIJȐ Įʌȩ IJȠȞ ȤȡȒıIJȘ ȞĮ İȚıȐȖİȚ IJĮ ıIJȠȚȤİȓĮ IJȠȣ țĮȜĮșȠıijĮȚȡȚıIJȒ țĮȚ ıIJȘȞ ıȣȞȑȤİȚĮ IJĮ İțIJȣʌȫȞİȚ ıIJȘȞ ȠșȩȞȘ ȝĮȗȓ ȝİ țĮIJȐȜȜȘȜĮ ȝȘȞȪȝĮIJĮ. DZıțȘıȘ 10.2 ȃĮ IJȡȠʌȠʌȠȚȒıİIJİ IJȠ ʌȡȩȖȡĮȝȝĮ ex101.pas (ĮʌȠșȘțİȪıIJİ IJȠ ȝİ IJȠ ȩȞȠȝĮ ex102.pas) ȫıIJİ ȞĮ ȠȡȓȗİȚ ʌȓȞĮțĮ ȝİ ıIJȠȚȤİȓĮ 5 țĮȜĮșȠıijĮȚȡȚıIJȫȞ, ȞĮ ȗȘIJȐ Įʌȩ IJȠ ȤȡȒıIJȘ ȞĮ İȚıȐȖİȚ IJĮ ıIJȠȚȤİȓĮ IJȦȞ 5 İȖȖȡĮijȫȞ IJȠȣ ʌȓȞĮțĮ țĮȚ ȞĮ IJĮ İțIJȣʌȫȞİȚ ıIJȘȞ ȠșȩȞȘ ȝİ IJȘȞ ȤȡȒıȘ İȞIJȠȜȫȞ İʌĮȞȐȜȘȥȘȢ. DZıțȘıȘ 10.3 ȂȓĮ İȖȖȡĮijȒ ȝİ ʌİįȓĮ: DzIJȠȢ, ȂȒȞĮȢ, ǾȝȑȡĮ, ȝʌȠȡİȓ ȞĮ ȤȡȘıȚȝȠʌȠȚȘșİȓ ȖȚĮ IJȘȞ țĮIJĮȤȫȡȚıȘ ȘȝİȡȠȝȘȞȚȫȞ. īȡȐȥIJİ ȑȞĮ ʌȡȩȖȡĮȝȝĮ, ex103.pas, ʌȠȣ ȞĮ ȤȡȘıȚȝȠʌȠȚİȓ IJȑIJȠȚȠȣ İȓįȠȣȢ İȖȖȡĮijȑȢ țĮȚ ȞĮ țȐȞİȚ IJĮ İȟȒȢ: ȞĮ įȑȤİIJĮȚ IJȘ ıȘȝİȡȚȞȒ ȘȝİȡȠȝȘȞȓĮ țĮȚ IJȘȞ ȘȝİȡȠȝȘȞȓĮ ȖȑȞȞȘıȘȢ țȐʌȠȚȠȣ ĮIJȩȝȠȣ țĮȚ ȞĮ ȣʌȠȜȠȖȓȗİȚ țĮȚ İȝijĮȞȓȗİȚ ıIJȘȞ ȠșȩȞȘ IJȘȞ ȘȜȚțȓĮ IJȠȣ. DZıțȘıȘ 10.4 īȡȐȥIJİ ʌȡȩȖȡĮȝȝĮ, ex104.pas, ıIJȠ ȠʌȠȓȠ ȞĮ ȠȡȓıİIJİ ʌȓȞĮțĮ ȝİ ıIJȠȚȤİȓĮ 5 İȖȖȡĮijȫȞ, ʌȠȣ șĮ ȤȡȘıȚȝȠʌȠȚİȓIJĮȚ ȦȢ ʌȡȠıȦʌȚțȩȢ įȚİȣșȣȞıȚȠȖȡȐijȠȢ. Ǿ țȐșİ İȖȖȡĮijȒ ȞĮ ȑȤİȚ IJĮ ʌĮȡĮțȐIJȦ ʌİįȓĮ: - ȩȞȠȝĮ - İʌȫȞȣȝȠ - IJȘȜȑijȦȞȠ - țȚȞȘIJȩ - e-mail - įȚİȪșȣȞıȘ - ʌȩȜȘ - IJĮȤȣįȡȠȝȚțȩ țȦįȚțȩ - ȘȝİȡȠȝȘȞȓĮ ȖȑȞȞȘıȘȢ (ȘȝȑȡĮ - ȝȒȞĮȢ - ȑIJȠȢ) ȉȠ ʌȡȩȖȡĮȝȝĮ ȞĮ ȗȘIJȐ Įʌȩ IJȠ ȤȡȒıIJȘ ȞĮ İȚıȐȖİȚ IJĮ ıIJȠȚȤİȓĮ IJȦȞ 5 İȖȖȡĮijȫȞ. ȈIJȘ ıȣȞȑȤİȚĮ ȞĮ ȗȘIJȐ, İʌȓıȘȢ, Įʌȩ IJȠȞ ȤȡȒıIJȘ ȞĮ ʌȜȘțIJȡȠȜȠȖȒıİȚ ȑȞĮ İʌȫȞȣȝȠ, țĮȚ ȞĮ İțIJȣʌȫȞİȚ ıIJȘȞ ȠșȩȞȘ IJȘȞ ʌȡȫIJȘ İȖȖȡĮijȒ IJȘȢ ȠʌȠȓĮȢ IJȠ İʌȫȞȣȝȠ İȓȞĮȚ ȓįȚȠ ȝİ IJȠ İʌȫȞȣȝȠ IJȠ ȠʌȠȓȠ ʌȜȘțIJȡȠȜȩȖȘıİ Ƞ ȤȡȒıIJȘȢ (ĮȞ ȣʌȐȡȤİȚ). ȈǾȂǼǿȍȈǼǿȈ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________

ǹș. Ǽ. ȀȠȣIJıȠȞȚțȩȜĮȢ


58

ǹȈȀǾȈǾ 10

_____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________


59

ǹȈȀǾȈǾ 11 ǹȡȤİȓĮ 11.1 ǼȚıĮȖȦȖȒ H Pascal ȣʌȠıIJȘȡȓȗİȚ IJȘȞ ĮȞȐȖȞȦıȘ țĮȚ İȖȖȡĮijȒ ĮȡȤİȓȦȞ ȝİ IJȘȞ ȤȡȒıȘ țĮIJȐȜȜȘȜȦȞ ıȣȞĮȡIJȒıİȦȞ, įȚĮįȚțĮıȚȫȞ țĮȚ ȝİIJĮȕȜȘIJȫȞ. ȉĮ ĮȡȤİȓĮ įȚĮțȡȓȞȠȞIJĮȚ ıİ ĮȡȤİȓĮ țİȚȝȑȞȠȣ (text files), ĮȡȤİȓĮ ȝİ IJȪʌȠ (typed files) țĮȚ ĮȡȤİȓĮ ȤȦȡȓȢ IJȪʌȠ (untyped files). ȉĮ ĮȡȤİȓĮ ȤȦȡȓȢ IJȪʌȠ įİȞ șĮ ȝĮȢ ĮʌĮıȤȠȜȒıȠȣȞ ı'ĮȣIJȑȢ IJȚȢ ıȘȝİȚȫıİȚȢ. īȚĮ IJȘȞ ĮȞȐȖȞȦıȘ / İȖȖȡĮijȒ İȞȩȢ ĮȡȤİȓȠȣ İȓȞĮȚ ĮʌĮȡĮȓIJȘIJȠ ȞĮ ȠȡȚıșİȓ țȐʌȠȚĮ ȝİIJĮȕȜȘIJȒ ȝİ IJȘȞ ȠʌȠȓĮ ȖȓȞİIJĮȚ Ș ĮȞĮijȠȡȐ ıIJȠ ĮȡȤİȓȠ țĮȚ ıIJȘȞ ıȣȞȑȤİȚĮ ȞĮ ȖȓȞİȚ Ș ıȣıȤȑIJȚıȘ IJȘȢ ȝİIJĮȕȜȘIJȒȢ ĮȣIJȒȢ ȝİ IJȠ ȩȞȠȝĮ IJȠȣ ĮȡȤİȓȠȣ ıIJȠ ȜİȚIJȠȣȡȖȚțȩ ıȪıIJȘȝĮ. 11.2 ȀĮșȠȡȚıȝȩȢ ȂİIJĮȕȜȘIJȒȢ ǹȡȤİȓȠȣ ȅ țĮșȠȡȚıȝȩȢ ȝİIJĮȕȜȘIJȒȢ ĮȡȤİȓȠȣ țİȚȝȑȞȠȣ ȖȓȞİIJĮȚ ȝİ IJȘȞ ʌĮȡĮțȐIJȦ įȒȜȦıȘ: Var ȩȞȠȝĮ_ȝİIJĮȕȜȘIJȒȢ_ĮȡȤİȓȠȣ : Text; ȈIJȘȞ ʌĮȡĮʌȐȞȦ įȒȜȦıȘ, Text İȓȞĮȚ IJȪʌȠȢ įİįȠȝȑȞȦȞ (ȩʌȦȢ Integer, Real, ț.Ȝ.ʌ.) Ƞ ȠʌȠȓȠȢ ʌĮȡȚıIJȐȞİȚ ĮȡȤİȓĮ țİȚȝȑȞȠȣ. ȅ țĮșȠȡȚıȝȩȢ ȝİIJĮȕȜȘIJȒȢ ĮȡȤİȓȠȣ ȝİ IJȪʌȠ ȖȓȞİIJĮȚ ȝİ IJȘȞ ʌĮȡĮțȐIJȦ įȒȜȦıȘ: Var ȩȞȠȝĮ_ȝİIJĮȕȜȘIJȒȢ_ĮȡȤİȓȠȣ : File of IJȪʌȠȢ; ȩʌȠȣ IJȪʌȠȢ İȓȞĮȚ țȐʌȠȚȠȢ IJȪʌȠȢ įİįȠȝȑȞȦȞ (ȩʌȦȢ Integer, Real, Ȓ ȠʌȠȚȠıįȒʌȠIJİ ȐȜȜȠȢ ĮʌȜȩȢ Ȓ įȠȝȘȝȑȞȠȢ IJȪʌȠȢ įİįȠȝȑȞȦȞ). īȚĮ ʌĮȡȐįİȚȖȝĮ ȝİ IJȚȢ ʌĮȡĮțȐIJȦ įȘȜȫıİȚȢ ȠȡȓȗȠȣȝİ ȝİIJĮȕȜȘIJȑȢ ĮȡȤİȓȦȞ įİįȠȝȑȞȦȞ ʌȡĮȖȝĮIJȚțȫȞ ĮȡȚșȝȫȞ, ĮțİȡĮȓȦȞ ĮȡȚșȝȫȞ țĮȚ İȖȖȡĮijȫȞ IJȪʌȠȣ PersonData (IJȠȞ ȠʌȠȓȠ ȠȡȓȗȠȣȝİ ʌȡȠȘȖȠȣȝȑȞȦȢ): Type PersonData = Record Name : String[20]; Age : Integer; End; Var TextFile1 : Text; DataFile1 : File of Real; DataFile2 : File of Integer; DataFile3 : File of PersonData;

11.3 ȈȣıȤȑIJȚıȘ ȂİIJĮȕȜȘIJȒȢ ǹȡȤİȓȠȣ ȝİ ǵȞȠȝĮ ǹȡȤİȓȠȣ Ǿ ȝİIJĮȕȜȘIJȒ İȞȩȢ ĮȡȤİȓȠȣ ȩʌȦȢ IJȘȞ ȠȡȓıĮȝİ ʌȡȠȘȖȠȣȝȑȞȦȢ, (ȜȑȖİIJĮȚ İʌȓıȘȢ țĮȚ İıȦIJİȡȚțȩ ȩȞȠȝĮ IJȠȣ ĮȡȤİȓȠȣ), İȓȞĮȚ IJȠ ȩȞȠȝĮ IJȠȣ ĮȡȤİȓȠȣ ȩʌȦȢ İȓȞĮȚ ȖȞȦıIJȩ ıIJȠ ʌȡȩȖȡĮȝȝȐ ȝĮȢ. ǹʌȩ IJȘȞ ȐȜȜȘ, IJȠ ȩȞȠȝĮ IJȠȣ ĮȡȤİȓȠȣ ȝİ IJȠ ȠʌȠȓȠ ĮȣIJȩ İȓȞĮȚ ȖȞȦıIJȩ ıIJȠ ȜİȚIJȠȣȡȖȚțȩ ıȪıIJȘȝĮ (ʌ.Ȥ. ıIJȠ DOS), ȜȑȖİIJĮȚ ĮʌȜȫȢ ȩȞȠȝĮ (Ȓ İȟȦIJİȡȚțȩ ȩȞȠȝĮ) țĮȚ İȓȞĮȚ IJȠ ȩȞȠȝĮ IJȠȣ ĮȡȤİȓȠȣ ȩʌȦȢ ĮȣIJȩ ĮʌȠșȘțİȪİIJĮȚ ıIJȠ įȓıțȠ IJȠȣ Ǿ/Ȋ. Ȉİ țȐșİ ʌȡȩȖȡĮȝȝĮ ʌȠȣ ȤȡȘıȚȝȠʌȠȚİȓ ĮȡȤİȓĮ, șĮ ʌȡȑʌİȚ țĮIJĮȡȤȐȢ ȞĮ ıȣıȤİIJȚıIJİȓ Ș ȝİIJĮȕȜȘIJȒ ĮȡȤİȓȠȣ ȝİ IJȠ ȩȞȠȝĮ IJȠȣ ĮȡȤİȓȠȣ. Ǿ ıȣıȤȑIJȚıȘ ĮȣIJȒ ȖȓȞİIJĮȚ ȝİ IJȘȞ įȚĮįȚțĮıȓĮ Assign, ȩʌȦȢ ijĮȓȞİIJĮȚ ʌĮȡĮțȐIJȦ: Assign(ȩȞȠȝĮ_ȝİIJĮȕȜȘIJȒȢ_ĮȡȤİȓȠȣ, İȟȦIJİȡȚțȩ_ȩȞȠȝĮ_ĮȡȤİȓȠȣ);


60

ǹȈȀǾȈǾ 11

ȆĮȡȐįİȚȖȝĮ: Assign(TextFile1, 'textdata.txt'); Assign(DataFile1, 'reals.dat'); Assign(DataFile2, 'integers.dat'); Assign(DataFile3, 'persons.dat'); ȈIJȠ ʌĮȡĮʌȐȞȦ ʌĮȡȐįİȚȖȝĮ IJĮ textdata.txt, reals.dat, integers.dat țĮȚ persons.dat İȓȞĮȚ IJĮ ȠȞȩȝĮIJĮ IJȦȞ ĮȡȤİȓȦȞ ȩʌȦȢ ĮȣIJȐ ıȫȗȠȞIJĮȚ ıIJȠ įȓıțȠ ȝĮȢ. 11.4 DZȞȠȚȖȝĮ țĮȚ ȀȜİȓıȚȝȠ ǹȡȤİȓȠȣ ǹijȠȪ ıȣıȤİIJȓıȠȣȝİ IJȘȞ ȝİIJĮȕȜȘIJȒ ĮȡȤİȓȠȣ ȝİ IJȠ ȩȞȠȝĮ ĮȡȤİȓȠȣ țĮȚ ʌȡȚȞ țȐȞȠȣȝİ ȠIJȚįȒʌȠIJİ ȐȜȜȠ, șĮ ʌȡȑʌİȚ ȞĮ ĮȞȠȓȟȠȣȝİ IJȠ ĮȡȤİȓȠ. ǹȞȐȜȠȖĮ ȝİ IJȠ ıțȠʌȩ ȖȚĮ IJȠȞ ȠʌȠȓȠ ȖȓȞİIJĮȚ IJĮ ȐȞȠȚȖȝĮ IJȠȣ ĮȡȤİȓȠȣ ȤȡȘıȚȝȠʌȠȚȠȪȞIJĮȚ ȠȚ ʌĮȡĮțȐIJȦ įȚĮįȚțĮıȓİȢ: Reset (ȩȞȠȝĮ_ȝİIJĮȕȜȘIJȒȢ_ĮȡȤİȓȠȣ); ǹȞȠȓȖİȚ ȑȞĮ ĮȡȤİȓȠ IJȠ ȠʌȠȓȠ ʌȡȑʌİȚ ȒįȘ ȞĮ ȣʌȐȡȤİȚ, ȖȚĮ ĮȞȐȖȞȦıȘ Ȓ İȖȖȡĮijȒ. Rewrite (ȩȞȠȝĮ_ȝİIJĮȕȜȘIJȒȢ_ĮȡȤİȓȠȣ); ǻȘȝȚȠȣȡȖİȓ ȑȞĮ ȞȑȠ ĮȡȤİȓȠ ȖȚĮ İȖȖȡĮijȒ. ǹȞ IJȠ ĮȡȤİȓȠ ȣʌȐȡȤİȚ, IJĮ ʌİȡȚİȤȩȝİȞȐ IJȠȣ țĮIJĮıIJȡȑijȠȞIJĮȚ, İȞȫ ĮȞ įİȞ ȣʌȐȡȤİȚ įȘȝȚȠȣȡȖİȓIJĮȚ. ǹppend (ȩȞȠȝĮ_ȝİIJĮȕȜȘIJȒȢ_ĮȡȤİȓȠȣ); ǹȞȠȓȖİȚ ȑȞĮ ĮȡȤİȓȠ țİȚȝȑȞȠȣ IJȠ ȠʌȠȓȠ ʌȡȑʌİȚ ȒįȘ ȞĮ ȣʌȐȡȤİȚ, ȖȚĮ ʌȡȠıșȒțȘ ıIJȠ IJȑȜȠȢ IJȠȣ. ǹijȠȪ IJİȜİȚȫıȠȣȝİ ȝİ IJȘȞ ĮȞȐȖȞȦıȘ / İȖȖȡĮijȒ İȞȩȢ ĮȡȤİȓȠȣ, ʌȡȑʌİȚ ȞĮ țȜİȓıȠȣȝİ IJȠ ĮȡȤİȓȠ ȝİ IJȘȞ İȞIJȠȜȒ Close, ʌ.Ȥ.: Close (ȩȞȠȝĮ_ȝİIJĮȕȜȘIJȒȢ_ĮȡȤİȓȠȣ);

11.5 ǹȞȐȖȞȦıȘ / ǼȖȖȡĮijȒ ǹȡȤİȓȦȞ Ǿ ĮȞȐȖȞȦıȘ / İȖȖȡĮijȒ ĮȡȤİȓȦȞ ȖȓȞİIJĮȚ ȝİ IJȚȢ İȞIJȠȜȑȢ Read țĮȚ Write. ǹȣIJȑȢ ıȣȞIJȐııȠȞIJĮȚ ȩʌȦȢ ȟȑȡȠȣȝİ, ȖȚĮ IJȠ įȚȐȕĮıȝĮ Įʌȩ IJȠ ʌȜȘțIJȡȠȜȩȖȚȠ țĮȚ IJȘȞ İțIJȪʌȦıȘ ıIJȘȞ ȠșȩȞȘ, ȝȩȞȠ ʌȠȣ IJȫȡĮ ʌȡȑʌİȚ ȞĮ ʌİȡȚȑȤȠȣȞ ıĮȞ ʌȡȫIJȘ ʌĮȡȐȝİIJȡȠ IJȘȞ ȝİIJĮȕȜȘIJȒ IJȠȣ ĮȡȤİȓȠȣ Įʌȩ IJȠ ȠʌȠȓȠ įȚĮȕȐȗȠȣȝİ Ȓ ıIJȠ ȠʌȠȓȠ ȖȡȐijȠȣȝİ. ȆĮȡĮįİȓȖȝĮIJĮ: Write(TextFile1, 'abcdef'); īȡȐijİȚ IJȠ ĮȜijĮȡȚșȝȘIJȚțȩ 'abcdef' ıIJȠ ĮȡȤİȓȠ TextFile1.

Write(DataFile1, 2.54); īȡȐijİȚ IJȠȞ ĮȡȚșȝȩ 2.54 ıIJȠ ĮȡȤİȓȠ DataFile1. Read(TextFile1,x); ǻȚĮȕȐȗİȚ IJȘȞ ĮȜijĮȡȚșȝȘIJȚțȒ ȝİIJĮȕȜȘIJȒ x Įʌȩ IJȠ ĮȡȤİȓȠ TextFile1. ǼȚįȚțȩIJİȡĮ, ȝȩȞȠ ȖȚĮ IJĮ ĮȡȤİȓĮ țİȚȝȑȞȠȣ ȝʌȠȡȠȪȞ ȞĮ ȤȡȘıȚȝȠʌȠȚȘșȠȪȞ ȠȚ İȞIJȠȜȑȢ Readln țĮȚ Writeln, ȝİ IJȚȢ ȠʌȠȓİȢ įȚĮȕȐȗİIJĮȚ Ȓ ȖȡȐijİIJĮȚ ȝȓĮ ȠȜȩțȜȘȡȘ ȖȡĮȝȝȒ IJȠȣ ĮȡȤİȓȠȣ.


ǹȡȤİȓĮ

61

11.6 ȈİȚȡȚĮțȒ / ȉȣȤĮȓĮ ȆȡȠıʌȑȜĮıȘ ıİ ǹȡȤİȓȠ ȀȐșİ ĮȡȤİȓȠ ıȤİIJȓȗİIJĮȚ ȝİ țȐʌȠȚȠȞ įİȓțIJȘ Ƞ ȠʌȠȓȠȢ įİȓȤȞİȚ IJȘȞ șȑıȘ ıIJȘȞ ȠʌȠȓĮ ȕȡȚıțȩȝĮıIJİ ıIJȠ ĮȡȤİȓȠ. ȂİIJȐ Įʌȩ țȐʌȠȚĮ İȞIJȠȜȒ ĮȞȐȖȞȦıȘȢ Ȓ İȖȖȡĮijȒȢ, Ƞ įİȓțIJȘȢ ȝİIJĮțȚȞİȓIJĮȚ ȫıIJİ ȞĮ įİȓȤȞİȚ ıIJȘȞ İʌȩȝİȞȘ șȑıȘ İȓIJİ ȖȚĮ ĮȞȐȖȞȦıȘ İȓIJİ ȖȚĮ İȖȖȡĮijȒ. ǵIJĮȞ ȑȞĮ ĮȡȤİȓȠ ĮȞȠȓȖİIJĮȚ ȖȚĮ ĮȞȐȖȞȦıȘ / İȖȖȡĮijȒ ȝİ IJȘȞ įȚĮįȚțĮıȓĮ Reset, Ȓ įȘȝȚȠȣȡȖİȓIJĮȚ ȝİ IJȘȞ įȚĮįȚțĮıȓĮ Rewrite, Ƞ įİȓțIJȘȢ șȑıȘȢ IJȠȣ ĮȡȤİȓȠȣ įİȓȤȞİȚ ıIJȘȞ ĮȡȤȒ IJȠȣ ĮȡȤİȓȠȣ. ǹȞIJȓșİIJĮ ȩIJĮȞ ȑȞĮ ĮȡȤİȓȠ ĮȞȠȚȤșİȓ ȝİ IJȘȞ įȚĮįȚțĮıȓĮ Append, IJȩIJİ Ƞ įİȓțIJȘȢ IJȠȣ ĮȡȤİȓȠȣ įİȓȤȞİȚ ıIJȠ IJȑȜȠȢ IJȠȣ ĮȡȤİȓȠȣ. ȈİȚȡȚĮțȒ ʌȡȠıʌȑȜĮıȘ ıİ ĮȡȤİȓȠ ȑȤȠȣȝİ ȩIJĮȞ įȚĮȕȐȗȠȣȝİ Ȓ ȖȡȐijȠȣȝİ ȑȞĮ ĮȡȤİȓȠ ȟİțȚȞȫȞIJĮȢ Įʌȩ IJȘȞ ĮȡȤȒ IJȠȣ țĮȚ ıȣȞİȤȓȗȠȣȝİ įȚĮįȠȤȚțȐ ȝȑȤȡȚ IJȠ IJȑȜȠȢ. ȉȣȤĮȓĮ Ȓ ȐȝİıȘ ʌȡȠıʌȑȜĮıȘ ıİ ĮȡȤİȓȠ ȑȤȠȣȝİ ȩIJĮȞ ȝİIJĮȕĮȓȞȠȣȝİ İʌȚȜİțIJȚțȐ ıİ įȚȐijȠȡĮ ıȘȝİȓĮ IJoȣ ĮȡȤİȓȠȣ țĮȚ įȚĮȕȐȗȠȣȝİ, ȖȡȐijȠȣȝİ Ȓ IJȡȠʌȠʌȠȚȠȪȝİ IJĮ įİįȠȝȑȞĮ IJȠȣ ĮȡȤİȓȠȣ. īȚĮ IJȘȞ ʌȡȠıʌȑȜĮıȘ / ȑȜİȖȤȠ IJȠȣ įİȓțIJȘ șȑıȘȢ İȞȩȢ ĮȡȤİȓȠȣ ȤȡȘıȚȝȠʌȠȚȠȪȞIJĮȚ ȠȚ ʌĮȡĮțȐIJȦ įȚĮįȚțĮıȓİȢ țĮȚ ıȣȞĮȡIJȒıİȚȢ: Eof (F: filetype): Boolean; ǼʌȚıIJȡȑijİȚ ĮȜȘșȒ IJȚȝȒ (TRUE) ȩIJĮȞ Ƞ įİȓțIJȘȢ IJȠȣ ĮȡȤİȓȠȣ ijIJȐıİȚ ıIJȠ IJȑȜȠȢ IJȠȣ ĮȡȤİȓȠȣ. Eoln (Var F: Text): Boolean; ǼʌȚıIJȡȑijİȚ ĮȜȘșȒ IJȚȝȒ (TRUE) ȩIJĮȞ Ƞ įİȓțIJȘȢ IJȠȣ ĮȡȤİȓȠȣ țİȚȝȑȞȠȣ ijIJȐıİȚ ıIJȠ IJȑȜȠȢ ȝȚĮȢ ȖȡĮȝȝȒȢ IJȠȣ ĮȡȤİȓȠȣ. Seek (Var F: filetype; N: LongInt); ȂİIJĮțȚȞİȓ IJȠ įİȓțIJȘ IJȠȣ ĮȡȤİȓȠȣ F ıIJȘȞ ĮȡȤȒ IJȘȢ İȖȖȡĮijȒȢ IJȠȣ ȝİ ĮȡȚșȝȩ ȃ. Ǿ ʌȡȫIJȘ İȖȖȡĮijȒ ȑȤİȚ ĮȡȚșȝȩ ȝȘįȑȞ. SeekEof (Var F: filetype): Boolean; ǼȓȞĮȚ ʌĮȡȩȝȠȚĮ ȝİ IJȘȞ Eof, ȝİ IJȘ įȚĮijȠȡȐ ȩIJȚ țĮIJȐ IJȘȞ ĮȞĮȗȒIJȘıȘ IJȠȣ IJȑȜȠȣȢ ĮȡȤİȓȠȣ ʌĮȡĮȜİȓʌİȚ IJĮ țİȞȐ įȚĮıIJȒȝĮIJĮ țĮȚ IJȠȣȢ ȤĮȡĮțIJȒȡİȢ IJȑȜȠȣȢ ȖȡĮȝȝȒȢ. SeekEoln (Var F: Text): Boolean; ǼȓȞĮȚ ʌĮȡȩȝȠȚĮ ȝİ IJȘȞ Eoln, ȝİ IJȘ įȚĮijȠȡȐ ȩIJȚ, ʌȡȚȞ İȜȑȖȟİȚ ȖȚĮ IJȠ IJȑȜȠȢ ȖȡĮȝȝȒȢ, ʌĮȡĮȜİȓʌİȚ IJĮ țİȞȐ įȚĮıIJȒȝĮIJĮ. FilePos (Var F: filetype): LongInt; ǼʌȚıIJȡȑijİȚ IJȠȞ ĮȡȚșȝȩ IJȘȢ İȖȖȡĮijȒȢ ıIJȘȞ ȠʌȠȓĮ ȕȡȓıțİIJĮȚ Ƞ įİȓțIJȘȢ IJȠȣ ĮȡȤİȓȠȣ. FileSize (Var F: filetype): LongInt; ǼʌȚıIJȡȑijİȚ IJȠȞ ĮȡȚșȝȩ IJȦȞ İȖȖȡĮijȫȞ ʌȠȣ ʌİȡȚȑȤİȚ IJȠ ĮȡȤİȓȠ.

ǹș. Ǽ. ȀȠȣIJıȠȞȚțȩȜĮȢ


62

ǹȈȀǾȈǾ 11

ȉȑȜȠȢ ȝİ IJĮ ĮȡȤİȓĮ ȝʌȠȡȠȪȝİ ȞĮ ȤȡȘıȚȝȠʌȠȚȒıȠȣȝİ țĮȚ IJȚȢ ʌĮȡĮțȐIJȦ įȚĮįȚțĮıȓİȢ: Erase (Var F: filetype); ǻȚĮȖȡȐijİȚ Įʌȩ IJȠ įȓıțȠ IJȠ ĮȡȤİȓȠ ʌȠȣ ȑȤİȚ ıȣıȤİIJȚıIJİȓ ȝİ IJȠ F. Rename (Var F: filetype ; NewName: String); ǹȜȜȐȗİȚ IJȠ ȩȞȠȝĮ IJȠȣ ĮȡȤİȓȠȣ (ʌȠȣ ȑȤİȚ ıȣıȤİIJȚıIJİȓ ȝİ IJȠ F), ȝİ IJȠ ȩȞȠȝĮ ʌȠȣ ȣʌȐȡȤİȚ ıIJȘȞ NewName.

11.7 ȋİȚȡȚıȝȩȢ ȁĮșȫȞ Ȉİ ʌİȡȓʌIJȦıȘ țĮIJȐ IJȘȞ ȠʌȠȓĮ ȖȓȞİȚ țȐʌȠȚȠ ȜȐșȠȢ ȤİȚȡȚıȝȠȪ ĮȡȤİȓȦȞ (Ȇ.Ȥ. ȐȞȠȚȖȝĮ ĮȡȤİȓȠȣ ȖȚĮ įȚȐȕĮıȝĮ IJȠ ȠʌȠȓȠ įİȞ ȣʌȐȡȤİȚ) IJȩIJİ ıIJĮȝĮIJȐ ȕȓĮȚĮ Ș İțIJȑȜİıȘ IJȠȣ ʌȡȠȖȡȐȝȝĮIJȠȢ. ǼȐȞ șȑȜȠȣȝİ Ƞ ȤİȚȡȚıȝȩȢ ȜĮșȫȞ ȞĮ ȖȓȞİIJĮȚ Įʌȩ IJȠ ʌȡȩȖȡĮȝȝĮ ȝĮȢ IJȩIJİ ʌȡȑʌİȚ ȞĮ țȐȞȠȣȝİ ȤȡȒıȘ IJȘȢ İʌȚȜȠȖȒȢ {$ǿ-} țĮȚ IJȘȢ ıȣȞȐȡIJȘıȘȢ IOResult. Ǿ İʌȚȜȠȖȒ {$ǿ-} ĮʌİȞİȡȖȠʌȠȚİȓ IJȘȞ ĮȣIJȩȝĮIJȘ ĮȞȓȤȞİȣıȘ ȜĮșȫȞ ĮȡȤİȓȦȞ Įʌȩ IJȠ ȁİȚIJȠȣȡȖȚțȩ ȈȪıIJȘȝĮ, İȞȫ ĮȞIJȓșİIJĮ Ș İʌȚȜȠȖȒ {$ǿ+} IJȘȞ İȞİȡȖȠʌȠȚİȓ. Ǿ ıȣȞȐȡIJȘıȘ IOResult İʌȚıIJȡȑijİȚ IJȚȝȒ įȚȐijȠȡȘ IJȠȣ 0 ıİ ʌİȡȓʌIJȦıȘ ʌȠȣ ʌĮȡȠȣıȚĮıșİȓ țȐʌȠȚȠ ıijȐȜȝĮ ıIJȠȞ ȤİȚȡȚıȝȩ ĮȡȤİȓȦȞ. ȆĮȡȐįİȚȖȝĮ: {$I-} {ǹʌİȞİȡȖȠʌȠȓȘıȘ ĮȞȓȤȞİȣıȘȢ ȜĮșȫȞ} Reset(DataFile1); {ǹȞȠȚȖȝĮ ĮȡȤİȓȠȣ ȖȚĮ ĮȞȐȖȞȦıȘ} {$I+} {ǼȞİȡȖȠʌȠȓȘıȘ ĮȞȓȤȞİȣıȘȢ ȜĮșȫȞ} ErrorCode := IOResult; If ErrorCode <> 0 then {ǼȜİȖȤȠȢ ȪʌĮȡȟȘȢ ȜȐșȠȣȢ} Begin Writeln('ȈijȐȜȝĮ ĮȞȠȓȖȝĮIJȠȢ ĮȡȤİȓȠȣ'); ... End Else ... {ǼȞIJȠȜȑȢ} 11.8 ȆĮȡĮįİȓȖȝĮIJĮ ȆĮȡȐįİȚȖȝĮ 1 īȡȐȥȚȝȠ ıİ ĮȡȤİȓȠȣ țİȚȝȑȞȠȣ. ȉȠ ʌĮȡĮțȐIJȦ ʌȡȩȖȡĮȝȝĮ įȘȝȚȠȣȡȖİȓ ȑȞĮ ĮȡȤİȓȠ ȝİ IJȠ ȩȞȠȝĮ textfile.txt țĮȚ ıIJȘȞ ıȣȞȑȤİȚĮ ȖȡȐijİȚ ȖȡĮȝȝȑȢ țİȚȝȑȞȠȣ IJȚȢ ȠʌȠȓİȢ ʌȜȘțIJȡȠȜȠȖİȓ Ƞ ȤȡȒıIJȘȢ ȝȑȤȡȚȢ ȩIJȠȣ Ƞ ȤȡȒıIJȘȢ ʌȜȘțIJȡȠȜȠȖȒıİȚ ȝȓĮ țİȞȒ ȖȡĮȝȝȒ țİȚȝȑȞȠȣ. Program WriteTextFile; Var f:Text; {ȠȡȚıȝȩȢ ȝİIJĮȕȜȘIJȒȢ ĮȡȤİȓȠȣ} s:String[80]; Begin Assign(f,'textfile.txt'); {ıȣıȤȑIJȚıȘ ȝİIJĮȕȜȘIJȒȢ ĮȡȤİȓȠȣ ȝİ ȩȞȠȝĮ ĮȡȤİȓȠȣ} Rewrite(f); {įȘȝȚȠȣȡȖȓĮ ĮȡȤİȓȠȣ} {ĮȞȐȖȞȦıȘ ȖȡĮȝȝȒȢ țİȚȝȑȞȠȣ Įʌȩ ʌȜȘțIJȡȠȜȩȖȚȠ țĮȚ İȖȖȡĮijȒ ıIJȠ ĮȡȤİȓȠ textfile.txt ȝȑȤȡȚ ȞĮ ʌȜȘțIJȡȠȜȠȖȒıİȚ Ƞ ȤȡȒıIJȘȢ țȐʌȠȚĮ țİȞȒ ȖȡĮȝȝȒ}


ǹȡȤİȓĮ

63

Repeat Readln(s); If s <> '' then Writeln(f,s); {İȖȖȡĮijȒ ȖȡĮȝȝȒȢ ĮȡȤİȓȠȣ} Until s=''; Close(f); {țȜİȓıȚȝȠ ĮȡȤİȓȠȣ} End. ȆĮȡȐįİȚȖȝĮ 2 ǹȞȐȖȞȦıȘ Įʌȩ ĮȡȤİȓȠȣ țİȚȝȑȞȠȣ. ȉȠ ʌĮȡĮțȐIJȦ ʌȡȩȖȡĮȝȝĮ įȚĮȕȐȗİȚ țĮȚ İțIJȣʌȫȞİȚ ıIJȘȞ ȠșȩȞȘ ȑȞĮ ȒįȘ ȣʌȐȡȤȠȞ ĮȡȤİȓȠ țİȚȝȑȞȠȣ ȝİ ȩȞȠȝĮ textfile.txt. Program ReadTextFile; Var f:Text; {ȠȡȚıȝȩȢ ȝİIJĮȕȜȘIJȒȢ ĮȡȤİȓȠȣ} s:String[80]; Begin Assign(f,'textfile.txt'); {ıȣıȤȑIJȚıȘ ȝİIJĮȕȜȘIJȒȢ ĮȡȤİȓȠȣ ȝİ ȩȞȠȝĮ ĮȡȤİȓȠȣ} Reset(f); {ȐȞȠȚȖȝĮ ĮȡȤİȓȠȣ ȖȚĮ ĮȞȐȖȞȦıȘ} While not eof(f) do {ȑȜİȖȤȠȢ IJȑȜȠȣȢ ĮȡȤİȓȠȣ} Begin Readln(f,s); {ĮȞȐȖȞȦıȘ Įʌȩ ĮȡȤİȓȠ} Writeln(s); End; Close(f); {țȜİȓıȚȝȠ ĮȡȤİȓȠȣ} End. ȆĮȡȐįİȚȖȝĮ 3 ȆȡȠıșȒțȘ ıİ ĮȡȤİȓȠȣ țİȚȝȑȞȠȣ. ȉȠ ʌĮȡĮțȐIJȦ ʌȡȩȖȡĮȝȝĮ ĮȞȠȓȖİȚ ȑȞĮ ȒįȘ ȣʌȐȡȤȠȞ ĮȡȤİȓȠ țİȚȝȑȞȠȣ țĮȚ ıIJȘȞ ıȣȞȑȤİȚĮ ʌȡȠıșȑIJİȚ ȖȡĮȝȝȑȢ țİȚȝȑȞȠȣ ıIJȠ ĮȡȤİȓȠ IJȚȢ ȠʌȠȓİȢ ʌȜȘțIJȡȠȜȠȖİȓ Ƞ ȤȡȒıIJȘȢ ȝȑȤȡȚȢ ȩIJȠȣ Ƞ ȤȡȒıIJȘȢ ʌȜȘțIJȡȠȜȠȖȒıİȚ ȝȓĮ țİȞȒ ȖȡĮȝȝȒ țİȚȝȑȞȠȣ. Program AppendTextFile; Var f:Text; {ȠȡȚıȝȩȢ ȝİIJĮȕȜȘIJȒȢ ĮȡȤİȓȠȣ} s:String[80]; Begin Assign(f,'textfile.txt'); {ıȣıȤȑIJȚıȘ ȝİIJĮȕȜȘIJȒȢ ĮȡȤİȓȠȣ ȝİ ȩȞȠȝĮ ĮȡȤİȓȠȣ} Append(f); {ȐȞȠȚȖȝĮ ĮȡȤİȓȠȣ ȖȚĮ ʌȡȩıșİıȘ ıIJȠ IJȑȜȠȢ} Repeat Readln(s); If s <> '' then Writeln(f,s); {İȖȖȡĮijȒ ȖȡĮȝȝȒȢ ĮȡȤİȓȠȣ} Until s=''; Close(f); {țȜİȓıȚȝȠ ĮȡȤİȓȠȣ} End.

ǹș. Ǽ. ȀȠȣIJıȠȞȚțȩȜĮȢ


64

ǹȈȀǾȈǾ 11

11.9 ǹıțȒıİȚȢ DZıțȘıȘ 11.1 īȡȐȥIJİ ʌȡȩȖȡĮȝȝĮ, ex111.pas, IJȠ ȠʌȠȓȠ ȞĮ ȗȘIJȐ Įʌȩ IJȠȞ ȤȡȒıIJȘ ȞĮ İȚıȐȖİȚ IJȠ ȩȞȠȝĮ İȞȩȢ ĮȡȤİȓȠȣ țİȚȝȑȞȠȣ țĮȚ ıIJȘȞ ıȣȞȑȤİȚĮ ȞĮ İȝijĮȞȓȗİȚ IJȠ țİȓȝİȞȠ ıIJȘȞ ȠșȩȞȘ. Ȉİ ʌİȡȓʌIJȦıȘ ʌȠȣ IJȠ ĮȡȤİȓȠ įİȞ ȣʌȐȡȤİȚ, ȞĮ ȗȘIJİȓIJĮȚ Įʌȩ IJȠȞ ȤȡȒıIJȘ ȑȞĮ ȞȑȠ ȩȞȠȝĮ ĮȡȤİȓȠȣ. DZıțȘıȘ 11.2 īȡȐȥIJİ ʌȡȩȖȡĮȝȝĮ, ex112.pas, IJȠ ȠʌȠȓȠ ȞĮ ȗȘIJȐ Įʌȩ IJȠȞ ȤȡȒıIJȘ ȞĮ İȚıȐȖİȚ IJȠ ȩȞȠȝĮ İȞȩȢ ĮȡȤİȓȠȣ țİȚȝȑȞȠȣ țĮȚ ıIJȘȞ ıȣȞȑȤİȚĮ ȞĮ ȝİIJȡȐ IJĮ ȖȡȐȝȝĮIJĮ, IJȚȢ ȜȑȟİȚȢ țĮȚ IJȚȢ ʌȡȠIJȐıİȚȢ IJȠȣ ĮȡȤİȓȠȣ ĮȣIJȠȪ. Ȉİ ʌİȡȓʌIJȦıȘ ʌȠȣ IJȠ ĮȡȤİȓȠ įİȞ ȣʌȐȡȤİȚ, ȞĮ ȗȘIJİȓIJĮȚ Įʌȩ IJȠȞ ȤȡȒıIJȘ ȑȞĮ ȞȑȠ ȩȞȠȝĮ ĮȡȤİȓȠȣ. DZıțȘıȘ 11.3 īȡȐȥIJİ ʌȡȩȖȡĮȝȝĮ, ex113.pas, IJȠ ȠʌȠȓȠ ȞĮ įȘȝȚȠȣȡȖİȓ ȑȞĮ ĮȡȤİȓȠ İȖȖȡĮijȫȞ ıʌȠȣįĮıIJȫȞ ȝİ ȩȞȠȝĮ students.dat. Ǿ țȐșİ İȖȖȡĮijȒ ȞĮ ʌİȡȚȜĮȝȕȐȞİȚ IJȚȢ ʌȜȘȡȠijȠȡȓİȢ: 1. ǹȡȚșȝȩȢ ȝȘIJȡȫȠȣ 2. ȅȞȠȝĮIJİʌȫȞȣȝȠ 3. ĭȪȜȜȠ ('ǹ' ȖȚĮ IJȠȣȢ ȐȞįȡİȢ țĮȚ 'ī' ȖȚĮ IJȚȢ ȖȣȞĮȓțİȢ) 4. ǺĮșȝȩȢ. Ǿ İȚıĮȖȦȖȒ İȖȖȡĮijȫȞ ıIJȠ ĮȡȤİȓȠ ȞĮ ıIJĮȝĮIJȐİȚ ȩIJĮȞ įȠșİȓ ĮȡȚșȝȩȢ ȝȘIJȡȫȠȣ ȓıȠȢ ȝİ IJȠ ȝȘįȑȞ. DZıțȘıȘ 11.4 īȡȐȥIJİ ʌȡȩȖȡĮȝȝĮ, ex114.pas, IJȠ ȠʌȠȓȠ ȞĮ ĮȞȠȓȖİȚ IJȠ ĮȡȤİȓȠ students.dat ʌȠȣ įȘȝȚȠȣȡȖȒıĮIJİ ıIJȘȞ ʌȡȠȘȖȠȪȝİȞȘ ȐıțȘıȘ țĮȚ Įʌȩ IJȚȢ İȖȖȡĮijȑȢ ĮȣIJȠȪ ȞĮ įȘȝȚȠȣȡȖİȓ įȪȠ ȞȑĮ ĮȡȤİȓĮ, ȑIJıȚ ȫıIJİ ıIJȠ ȑȞĮ, ȝİ ȩȞȠȝĮ male.dat, ȞĮ țĮIJĮȤȦȡȠȪȞIJĮȚ ȩȜȠȚ ȠȚ ıʌȠȣįĮıIJȑȢ țĮȚ ıIJȠ ȐȜȜȠ, female.dat, ȩȜİȢ ȠȚ ıʌȠȣįȐıIJȡȚİȢ. ȈǾȂǼǿȍȈǼǿȈ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________


ǹȡȤİȓĮ

65

_____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________

ǹș. Ǽ. ȀȠȣIJıȠȞȚțȩȜĮȢ


66

ǹȈȀǾȈǾ 11

_____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________


67

ȆǹȇǹȇȉǾȂǹ ǹ'

ȉȅ ȈȊȃȅȁȅ ȋǹȇǹȀȉǾȇȍȃ ASCII ǻİțĮįȚțȩȢ ǻİțĮİȟ/țȩȢ ȋĮȡĮțIJȒȡĮȢ 0 1 2 3

00 01 02 03

4

04

5 6

ȆȜȒțIJȡȠ

ȋĮȡĮțIJȒȡĮȢ İȜȑȖȤȠȣ

j

Ctrl-2 Ctrl-A Ctrl-B Ctrl-C

NUL SOH STX ETX

Null Start Of Heading Start Of Text End Of Text

i

Ctrl-D

EOT

End Of Transmission

05

h

Ctrl-E

ENQ

Enquiry

06

k

Ctrl-F

ACK

Acknowledge

x

Ctrl-G

BEL

Bell

Ctrl-H Ctrl-I Ctrl-J Ctrl-K Ctrl-L Ctrl-M Ctrl-N Ctrl-O Ctrl-P Ctrl-Q Ctrl-R Ctrl-S Ctrl-T Ctrl-U Ctrl-V Ctrl-W Ctrl-X

BS HT LF VT FF CR SO SI DLE DC1 DC2 DC3 DC4 NAK SYN ETB CAN

Backspace Horizontal Tabulation Line Feed Vertical Tabulation Form Feed Carriage Return Shift Out Shift In Data Link Escape Device Control 1 Device Control 2 Device Control 3 Device Control 4 Negative Acknowledge Synchronous Idle End of Transmission Block Cancel

7

07

8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24

08 09 0A 0B 0C 0D 0E 0F 10 11 12 13 14 15 16 17 18

n

25

19

p

Ctrl-Y

EM

End Of Medium

26

1A

o

Ctrl-Z

SUB

Substitute

27

1B

m

Ctrl-[

ESC

Escape

28 29

1C 1D

l

Ctrl-\ Ctrl-]

FS GS

File Separator Group Separator

30 31

1E 1F

Ctrl-6 Ctrl-_

RS US

Record Separator Unit Separator

Ľ !! ¶ §

Ÿ ź


68

ȆǹȇǹȇȉǾȂǹ

ǻİțĮįȚțȩȢ ǻİțĮİȟ/țȩȢ ȋĮȡĮțIJȒȡĮȢ ȆȜȒțIJȡȠ ǻİțĮįȚțȩȢ ǻİțĮİȟ/țȩȢ ȋĮȡĮțIJȒȡĮȢ ȆȜȒțIJȡȠ 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73

20 21 22 23 24 25 26 27 28 29 2A 2B 2C 2D 2E 2F 30 31 32 33 34 35 36 37 38 39 3A 3B 3C 3D 3E 3F 40 41 42 43 44 45 46 47 48 49

! ' # $ % & ' ( ) * + , . / 0 1 2 3 4 5 6 7 8 9 : ; < = > ? @ A B C D E F G H I

Space ! ' # $ % & ' ( ) * + , . / 0 1 2 3 4 5 6 7 8 9 : ; < = > ? @ A B C D E F G H I

74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115

4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 5B 5C 5D 5E 5F 60 61 62 63 64 65 66 67 68 69 6A 6B 6C 6D 6E 6F 70 71 72 73

J K L M N O P Q R S T U V W X Y Z [ \ ] ^ _ ` a b c d e f g h i j k l m n o p q r s

J K L M N O P Q R S T U V W X Y Z [ \ ] ^ _ ` a b c d e f g h i j k l m n o p q r s


ȉȠ ȈȪȞȠȜȠ ȋĮȡĮțIJȒȡȦȞ ASCII

ǻİțĮįȚțȩȢ ǻİțĮİȟ/țȩȢ ȋĮȡĮțIJȒȡĮȢ ȆȜȒțIJȡȠ ǻİțĮįȚțȩȢ ǻİțĮİȟ/țȩȢ ȋĮȡĮțIJȒȡĮȢ ȆȜȒțIJȡȠ 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156

ǹș. Ǽ. ȀȠȣIJıȠȞȚțȩȜĮȢ

74 75 76 77 78 79 7A 7B 7C 7D 7E 7F 80 81 82 83 84 85 86 87 88 89 8A 9B 9C 9D 8E 8F 90 91 92 93 94 95 96 97 98 99 9A 9B 9C

t u v w x y z { | } ~ ¨

ǹ Ǻ ī ǻ Ǽ ǽ Ǿ Ĭ ǿ Ȁ ȁ Ȃ ȃ Ȅ ȅ Ȇ ȇ Ȉ ȉ Ȋ ĭ ȋ Ȍ ȍ Į ȕ Ȗ į İ

t u v w x y z { | } ~ Del ǹ Ǻ ī ǻ Ǽ ǽ Ǿ Ĭ ǿ Ȁ ȁ Ȃ ȃ Ȅ ȅ Ȇ ȇ Ȉ ȉ Ȋ ĭ ȋ Ȍ ȍ Į ȕ Ȗ į İ

157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197

9D 9E 9F A0 A1 A2 A3 A4 A5 A6 A7 A8 A9 AA AB AC AD AE AF B0 B1 B2 B3 B4 B5 B6 B7 B8 B9 BA BB BC BD BE BF C0 C1 C2 C3 C4 C5

ȗ Ș ș Ț ț Ȝ ȝ Ȟ ȟ Ƞ ʌ ȡ ı Ȣ IJ ȣ ij Ȥ ȥ

ȗ Ș ș Ț ț Ȝ ȝ Ȟ ȟ Ƞ ʌ ȡ ı Ȣ IJ ȣ ij Ȥ ȥ Alt-176 Alt-177 Alt-178 Alt-179 Alt-180 Alt-181 Alt-182 Alt-183 Alt-184 Alt-185 Alt-186 Alt-187 Alt-188 Alt-189 Alt-190 Alt-191 Alt-192 Alt-193 Alt-194 Alt-195 Alt-196 Alt-197

69


70

ȆǹȇǹȇȉǾȂǹ

ǻİțĮįȚțȩȢ ǻİțĮİȟ/țȩȢ ȋĮȡĮțIJȒȡĮȢ ȆȜȒțIJȡȠ ǻİțĮįȚțȩȢ ǻİțĮİȟ/țȩȢ ȋĮȡĮțIJȒȡĮȢ ȆȜȒțIJȡȠ 198 199 200 201 202 203 204 205 206 207 208

C6 C7 C8 C9 CA CB CC CD CE CF D0

Alt-198 Alt-199 Alt-200 Alt-201 Alt-202 Alt-203 Alt-204 Alt-205 Alt-206 Alt-207 Alt-208

227 228 229 230 231 232 233 234 235 236 237

E3 E4 E5 E6 E7 E8 E9 EA EB EC ED

Ȓ ȧ ȓ ȩ Ȫ Ȩ ȫ

209

D1

Alt-209

238

EE

210 211 212 213 214 215 216 217

D2 D3 D4 D5 D6 D7 D8 D9

Alt-210 Alt-211 Alt-212 Alt-213 Alt-214 Alt-215 Alt-216 Alt-217

239 240 241 242 243 244 245 246

EF F0 F1 F2 F3 F4 F5 F6

 ŀ Ł ± • ” ń Ņ y

Alt-239 Alt-240 Alt-241 Alt-242 Alt-243 Alt-244 Alt-245 Alt-246

218

DA

Alt-218

247

F7

|

Alt-247

219

DB

Alt-219

248

F8

Alt-248

220

DC

Alt-220

249

F9

q .

221 222 223 224 225 226

DD DE DF E0 E1 E2

Ȧ Ȑ ȑ

Alt-221 Alt-222 Alt-223 Ȧ Alt-225 Alt-226

250 251 252 253 254 255

FA FB FC FD FE FF

Ù

į

’

I

.

¥ n 2

Ů

Alt-227 Alt-228 Alt-229 Alt-230 Alt-231 Alt-232 Alt-233 Alt-234 Alt-235 Alt-236 Alt-237 Alt-238

Alt-249 Alt-250 Alt-251 Alt-252 Alt-253 Alt-254 Alt-255


71

ǺǿǺȁǿȅīȇǹĭǿǹ 1. P. GROGONO, 'Programming In Pascal', Massachusetts, Addison-Wesley, 1984.

Second

Edition,

Reading,

2. K. JENSEN & N. WIRTH, 'Pascal User Manual and Report', Second Corrected Reprint of the Second Edition, Springer-Verlag, New York, 1978. 3. S. O'BRIEN, 'Turbo Pascal 6: The Complete Reference', McGraw-Hill Inc, 1991. 4. E. S. PAGE & L. B. WILSON, 'Information Manipulation and Representation using Pascal', Cambridge University Press, 1983. 5. S. D. PALMER, 'Mastering Turbo Pascal 6', Sybex Inc, 1991. 6. D. S. STIVISON, 'Introduction to Turbo Pascal', Sybex Inc, 1991. 7. N. WIRTH, 'Algorithms & Data Structures', Prentice-Hall (UK) Limited, London, 1986. 8. Ĭ. ǹȁǼǺǿǽȅȈ & ǹ. ȀǹȂȆȅȊȇǼȁǾȈ, 'ȂĮșȒȝĮIJĮ ȆȡȠȖȡĮȝȝĮIJȚıȝȠȪ: ǼȚıĮȖȦȖȒ ȝİ IJȘ īȜȫııĮ Pascal', ǻİȪIJİȡȘ DzțįȠıȘ, ǹșȒȞĮ 1988. 9. ȃ. ǹȃȉȍȃǹȀȅȈ ț.Ȑ., 'ǹȞȐʌIJȣȟȘ ǼijĮȡȝȠȖȫȞ ıİ ȆȡȠȖȡĮȝȝĮIJȚıIJȚțȩ ȆİȡȚȕȐȜȜȠȞ', ȈİȚȡȐ ȕȚȕȜȓȦȞ ȖȚĮ IJȘȞ ȉİȤȞȠȜȠȖȚțȒ ȀĮIJİȪșȣȞıȘ IJȘȢ ī' ȁȣțİȓȠȣ, ȆĮȚįĮȖȦȖȚțȩ ǿȞıIJȚIJȠȪIJȠ, ǹșȒȞĮ, 2000. 10. ǹ. ǹȉȂǹȉǽǿǻǾȈ & Ȃ. īȁǹȂȆǼǻǹȀǾȈ, 'Standard Pascal', ǴȦȞ, ǹșȒȞĮ, 1990. 11. ǹ. ǺǹȀǹȁǾ ț.Ȑ., 'ǹȞȐʌIJȣȟȘ ǼijĮȡȝȠȖȫȞ ıİ ȆȡȠȖȡĮȝȝĮIJȚıIJȚțȩ ȆİȡȚȕȐȜȜȠȞ', ȈİȚȡȐ ȕȚȕȜȓȦȞ ȖȚĮ IJȘȞ ȉİȤȞȠȜȠȖȚțȒ ȀĮIJİȪșȣȞıȘ IJȘȢ ī' ȁȣțİȓȠȣ, ȆĮȚįĮȖȦȖȚțȩ ǿȞıIJȚIJȠȪIJȠ, ǹșȒȞĮ, 2000. 12. ǿ. ǺȁǹȋǹǺǹȈ, 'Ǿ īȜȫııĮ ȆȡȠȖȡĮȝȝĮIJȚıȝȠȪ Pascal', ǼțįȩıİȚȢ īĮȡIJĮȖȐȞȘ, ĬİııĮȜȠȞȓțȘ, 1991. 13. Ȉ. ǻǾȂǾȉȇǿǹǻǾȈ, 'Turbo Pascal', ǴȦȞ, ǹșȒȞĮ, 1994. 14. ȁ. ȀǹȈȉȇǿȈǿȅȈ, 'Turbo Pascal ȖȚĮ Windows', Anubis, ǹșȒȞĮ, 1992. 15. ȉ. ȁǹǻǿǹȈ, 'Pascal, ȝȚĮ ȝİșȠįȚțȒ ʌȡȠıȑȖȖȚıȘ', ȀȜİȚįȐȡȚșȝȠȢ, ǹșȒȞĮ, 1991. 16. ȃ. ȂǿȈȊȇȁǾȈ, 'Pascal țĮȚ Turbo Pascal 5.0', ȈȣȝȝİIJȡȓĮ, ǹșȒȞĮ, 1990. 17. ǹ. ȈǿǻǼȇǿǻǾȈ ț.Ȑ., 'ȆȡȠȖȡĮȝȝĮIJȚıȝȩȢ ȊʌȠȜȠȖȚıIJȫȞ', ǺȚȕȜȓȠ ȖȚĮ IJȘȞ Ǻ ȉȐȟȘ IJȠȣ 1Ƞȣ ȀȪțȜȠȣ ȉ.Ǽ.Ǽ. IJȠȣ ȉȠȝȑĮ ȆȜȘȡȠijȠȡȚțȒȢ - ǻȚțIJȪȦȞ Ǿ/Ȋ, ȆĮȚįĮȖȦȖȚțȩ ǿȞıIJȚIJȠȪIJȠ, ǹșȒȞĮ, 2000.


ȆǼȇǿǼȋȅȂǼȃǹ ǹȈȀǾȈǾ 1

ȉȠ ȆİȡȚȕȐȜȜȠȞ IJȘȢ Turbo Pascal ............................................................ 1

ǹȈȀǾȈǾ 2

ǹʌȜȐ ȆȡȠȖȡȐȝȝĮIJĮ ................................................................................ 9

ǹȈȀǾȈǾ 3

ȊʌȠȜȠȖȚıȝȠȓ ȉȚȝȫȞ................................................................................ 17

ǹȈȀǾȈǾ 4

ǼȞIJȠȜȑȢ ǻȚĮțȜȐįȦıȘȢ ........................................................................... 23

ǹȈȀǾȈǾ 5

ǼȞIJȠȜȑȢ ǼʌĮȞȐȜȘȥȘȢ ............................................................................ 29

ǹȈȀǾȈǾ 6

ȊʌȠʌȡȠȖȡȐȝȝĮIJĮ ................................................................................. 35

ǹȈȀǾȈǾ 7

ȂȠȞȐįİȢ ................................................................................................ 41

ǹȈȀǾȈǾ 8

ȅȡȚȗȩȝİȞȠȚ ȉȪʌȠȚ ǻİįȠȝȑȞȦȞ................................................................ 45

ǹȈȀǾȈǾ 9

ȆȓȞĮțİȢ .................................................................................................. 49

ǹȈȀǾȈǾ 10

ǼȖȖȡĮijȑȢ............................................................................................... 53

ǹȈȀǾȈǾ 11

ǹȡȤİȓĮ.................................................................................................... 59

ȆǹȇǹȇȉǾȂǹ ȉȠ ȈȪȞȠȜȠ ȋĮȡĮțIJȒȡȦȞ ASCII.............................................................. 67 ǺǿǺȁǿȅīȇǹĭǿǹ .......................................................................................................... 71

ΔΟΜΗΜΕΝΟΣ ΠΡΟΓΡΑΜΜΑΤΙΣΜΟΣ ΓΛΩΣΣΑ PASCAL (ΕΡΓΑΣΤΗΡΙΟ)  

ΣΗΜΕΙΩΣΕΙΣ ΓΙΑ ΤΟ ΤΕΙ ΛΑΜΙΑΣ

Read more
Read more
Similar to
Popular now
Just for you