Home » Personal collection » Acorn hard disk » files » DomFord » INet/bio95_sm
INet/bio95_sm
This website contains an archive of files for the Acorn Electron, BBC Micro, Acorn Archimedes, Commodore 16 and Commodore 64 computers, which Dominic Ford has rescued from his private collection of floppy disks and cassettes.
Some of these files were originally commercial releases in the 1980s and 1990s, but they are now widely available online. I assume that copyright over them is no longer being asserted. If you own the copyright and would like files to be removed, please contact me.
Tape/disk: | Home » Personal collection » Acorn hard disk » files » DomFord |
Filename: | INet/bio95_sm |
Read OK: | ✔ |
File size: | 11F9 bytes |
Load address: | 0000 |
Exec address: | 0000 |
File contents
<TITLE>BIO 1995 Sample Problems</TITLE> <H2>The British Informatics Olympiad<BR> Sample Problems</H2> 15 March 1995<p> <HR> You should try to write computer programs to solve the following problems. The exact details of what your programs ask for or print does not matter, but they should clearly be able to do what is required. <p> It is in your interest to work on your own, as you will have to if you enter the British Informatics Olympiad; but you may consult other people if there are features of the programming language that you don't know how to use. You may have access to written notes, programming manuals, books or printed programs, and you may spend as long as you want on the problems (although they should only take you a few hours in total). Any programming language or computer system may be used, although Turbo Pascal on the PC is the recommended language for the BIO. <p> Don't worry if you make small mistakes, as it is the methods you use that are important. <p> If you can solve these problems without too many mistakes, you should enter for the <A HREF="http://www.eng.cam.ac.uk/external/bio/"> British Informatics Olympiad</A>. <p><HR> <p>Solutions to these problems can be found in <KBD><A HREF="samples.pas">samples.pas</A></KBD>.<p><HR> <H2>1. Prime Numbers</H2> A prime number is defined as any integer greater than one which contains no factors other than one and itself - that is, if there is no number between (and not including) 1 and N which can divide N with no remainder, then N is prime. <p> Your program should ask for a maximum number, M, and search for and print all prime numbers in the range 2..M. You should also display the number of prime numbers found. M will not be greater than 2000. <H3>Sample Output for Problem 1</H3> <p> Maximum number to test? 21<p> The following numbers between 2 and 21 are prime:<p> 2 3 5 7 11 13 17 19<p> A total of 8 prime numbers were found in this range.<p> <H2>2. Word Count</H2> You should write a program which asks for the name of a file and then counts the number of words in the file. A word is defined as any sequence of symbols separated by any combination of space characters and/or line breaks. <p> The file will not contain lines more than 127 characters long and will have a maximum of 20,000 words. <p> (Take care when creating a test file to make sure it ends with at least one blank line, otherwise it may be ignored by your programming language.) <p> <H3>Sample file for Problem 2: sample.fil</H3> The cat sat on the mat.<p> The cow jumped over the moon.<p> She sells sea shells on the sea shore.<p> <H3>Sample Output for Problem 2</H3> Name of file for word count? sample.fil<p> The file sample.fil contains 20 words.<p> <H2>3. Bubble sort</H2> To solve this problem you should write a program to sort numbers. It should read in integers from the keyboard, ending with and ignoring the number -999, sort them and print them in order, smallest first. There will be between 2 and 20 numbers to be sorted. <p> You may use a simple sorting method called bubblesort. This simply compares each number with its next neighbour in turn, swapping them if they are out of sequence, and repeatedly goes through the data until no more changes can be made. <p> <H3>Sample Output for Problem 3</H3> Type in up to 20 numbers, ending with -999:<p> 23<p> 12<p> 45<p> 32<p> 8<p> -1<p> 2<p> -999<p> The 7 sorted numbers are:<p> -1<p> 2<p> 8<p> 12<p> 23<p> 32<p> 45<p> <H2>End of BIO 1995 Sample Problems</H2> <HR> <H2>How to Enter the <A HREF="http://www.eng.cam.ac.uk/external/bio/"> British Informatics Olympiad</A></H2> If you have successfully completed any of these problems, you should be able to do well in the British Informatics Olympiad Round One. This competition is open to all students in secondary education who will be under 19 years old on 26 June, 1995. <p> Prizes and certificates will be awarded to all students who do well in the BIO. The top 10-15 will be invited to attend the second round and may win a place on the team to represent Great Britain at the prestigious International Olympiad in Informatics, which is being held in Eindhoven in the Netherlands from 26 June to 3 July, 1995. <p> To enter the British Informatics Olympiad, your teacher should write to <p> The British Informatics Olympiad<BR> Antony Rix, Christ's College, Cambridge CB2 3BU<p> enclosing a 57p S.A.E. The closing date for entries is 29 April, 1995 and solutions for the first round of the British Informatics Olympiad must be received by 7 May, 1995. <p> <HR> <ADDRESS> <EM> Antony Rix</EM></ADDRESS>
00000000 3c 54 49 54 4c 45 3e 42 49 4f 20 31 39 39 35 20 |<TITLE>BIO 1995 | 00000010 53 61 6d 70 6c 65 20 50 72 6f 62 6c 65 6d 73 3c |Sample Problems<| 00000020 2f 54 49 54 4c 45 3e 0a 3c 48 32 3e 54 68 65 20 |/TITLE>.<H2>The | 00000030 42 72 69 74 69 73 68 20 49 6e 66 6f 72 6d 61 74 |British Informat| 00000040 69 63 73 20 4f 6c 79 6d 70 69 61 64 3c 42 52 3e |ics Olympiad<BR>| 00000050 0a 53 61 6d 70 6c 65 20 50 72 6f 62 6c 65 6d 73 |.Sample Problems| 00000060 3c 2f 48 32 3e 0a 31 35 20 4d 61 72 63 68 20 31 |</H2>.15 March 1| 00000070 39 39 35 3c 70 3e 0a 3c 48 52 3e 0a 59 6f 75 20 |995<p>.<HR>.You | 00000080 73 68 6f 75 6c 64 20 74 72 79 20 74 6f 20 77 72 |should try to wr| 00000090 69 74 65 20 63 6f 6d 70 75 74 65 72 20 70 72 6f |ite computer pro| 000000a0 67 72 61 6d 73 20 74 6f 20 73 6f 6c 76 65 20 74 |grams to solve t| 000000b0 68 65 20 66 6f 6c 6c 6f 77 69 6e 67 0a 70 72 6f |he following.pro| 000000c0 62 6c 65 6d 73 2e 20 20 54 68 65 20 65 78 61 63 |blems. The exac| 000000d0 74 20 64 65 74 61 69 6c 73 20 6f 66 20 77 68 61 |t details of wha| 000000e0 74 20 79 6f 75 72 20 70 72 6f 67 72 61 6d 73 20 |t your programs | 000000f0 61 73 6b 20 66 6f 72 20 6f 72 20 70 72 69 6e 74 |ask for or print| 00000100 20 64 6f 65 73 0a 6e 6f 74 20 6d 61 74 74 65 72 | does.not matter| 00000110 2c 20 62 75 74 20 74 68 65 79 20 73 68 6f 75 6c |, but they shoul| 00000120 64 20 63 6c 65 61 72 6c 79 20 62 65 20 61 62 6c |d clearly be abl| 00000130 65 20 74 6f 20 64 6f 20 77 68 61 74 20 69 73 20 |e to do what is | 00000140 72 65 71 75 69 72 65 64 2e 0a 3c 70 3e 0a 49 74 |required..<p>.It| 00000150 20 69 73 20 69 6e 20 79 6f 75 72 20 69 6e 74 65 | is in your inte| 00000160 72 65 73 74 20 74 6f 20 77 6f 72 6b 20 6f 6e 20 |rest to work on | 00000170 79 6f 75 72 20 6f 77 6e 2c 20 61 73 20 79 6f 75 |your own, as you| 00000180 20 77 69 6c 6c 20 68 61 76 65 20 74 6f 20 69 66 | will have to if| 00000190 20 79 6f 75 0a 65 6e 74 65 72 20 74 68 65 20 42 | you.enter the B| 000001a0 72 69 74 69 73 68 20 49 6e 66 6f 72 6d 61 74 69 |ritish Informati| 000001b0 63 73 20 4f 6c 79 6d 70 69 61 64 3b 20 62 75 74 |cs Olympiad; but| 000001c0 20 79 6f 75 20 6d 61 79 20 63 6f 6e 73 75 6c 74 | you may consult| 000001d0 20 6f 74 68 65 72 20 70 65 6f 70 6c 65 0a 69 66 | other people.if| 000001e0 20 74 68 65 72 65 20 61 72 65 20 66 65 61 74 75 | there are featu| 000001f0 72 65 73 20 6f 66 20 74 68 65 20 70 72 6f 67 72 |res of the progr| 00000200 61 6d 6d 69 6e 67 20 6c 61 6e 67 75 61 67 65 20 |amming language | 00000210 74 68 61 74 20 79 6f 75 20 64 6f 6e 27 74 20 6b |that you don't k| 00000220 6e 6f 77 0a 68 6f 77 20 74 6f 20 75 73 65 2e 0a |now.how to use..| 00000230 59 6f 75 20 6d 61 79 20 68 61 76 65 20 61 63 63 |You may have acc| 00000240 65 73 73 20 74 6f 20 77 72 69 74 74 65 6e 20 6e |ess to written n| 00000250 6f 74 65 73 2c 20 70 72 6f 67 72 61 6d 6d 69 6e |otes, programmin| 00000260 67 20 6d 61 6e 75 61 6c 73 2c 20 62 6f 6f 6b 73 |g manuals, books| 00000270 20 6f 72 0a 70 72 69 6e 74 65 64 20 70 72 6f 67 | or.printed prog| 00000280 72 61 6d 73 2c 20 61 6e 64 20 79 6f 75 20 6d 61 |rams, and you ma| 00000290 79 20 73 70 65 6e 64 20 61 73 20 6c 6f 6e 67 20 |y spend as long | 000002a0 61 73 20 79 6f 75 20 77 61 6e 74 20 6f 6e 20 74 |as you want on t| 000002b0 68 65 20 70 72 6f 62 6c 65 6d 73 0a 28 61 6c 74 |he problems.(alt| 000002c0 68 6f 75 67 68 20 74 68 65 79 20 73 68 6f 75 6c |hough they shoul| 000002d0 64 20 6f 6e 6c 79 20 74 61 6b 65 20 79 6f 75 20 |d only take you | 000002e0 61 20 66 65 77 20 68 6f 75 72 73 20 69 6e 20 74 |a few hours in t| 000002f0 6f 74 61 6c 29 2e 20 20 41 6e 79 0a 70 72 6f 67 |otal). Any.prog| 00000300 72 61 6d 6d 69 6e 67 20 6c 61 6e 67 75 61 67 65 |ramming language| 00000310 20 6f 72 20 63 6f 6d 70 75 74 65 72 20 73 79 73 | or computer sys| 00000320 74 65 6d 20 6d 61 79 20 62 65 20 75 73 65 64 2c |tem may be used,| 00000330 20 61 6c 74 68 6f 75 67 68 20 54 75 72 62 6f 0a | although Turbo.| 00000340 50 61 73 63 61 6c 20 6f 6e 20 74 68 65 20 50 43 |Pascal on the PC| 00000350 20 69 73 20 74 68 65 20 72 65 63 6f 6d 6d 65 6e | is the recommen| 00000360 64 65 64 20 6c 61 6e 67 75 61 67 65 20 66 6f 72 |ded language for| 00000370 20 74 68 65 20 42 49 4f 2e 0a 3c 70 3e 0a 44 6f | the BIO..<p>.Do| 00000380 6e 27 74 20 77 6f 72 72 79 20 69 66 20 79 6f 75 |n't worry if you| 00000390 20 6d 61 6b 65 20 73 6d 61 6c 6c 0a 6d 69 73 74 | make small.mist| 000003a0 61 6b 65 73 2c 20 61 73 20 69 74 20 69 73 20 74 |akes, as it is t| 000003b0 68 65 20 6d 65 74 68 6f 64 73 20 79 6f 75 20 75 |he methods you u| 000003c0 73 65 20 74 68 61 74 20 61 72 65 20 69 6d 70 6f |se that are impo| 000003d0 72 74 61 6e 74 2e 0a 3c 70 3e 0a 49 66 20 79 6f |rtant..<p>.If yo| 000003e0 75 20 63 61 6e 20 73 6f 6c 76 65 20 74 68 65 73 |u can solve thes| 000003f0 65 20 70 72 6f 62 6c 65 6d 73 20 77 69 74 68 6f |e problems witho| 00000400 75 74 20 74 6f 6f 20 6d 61 6e 79 20 6d 69 73 74 |ut too many mist| 00000410 61 6b 65 73 2c 20 0a 79 6f 75 20 73 68 6f 75 6c |akes, .you shoul| 00000420 64 20 65 6e 74 65 72 20 66 6f 72 20 74 68 65 20 |d enter for the | 00000430 0a 3c 41 20 48 52 45 46 3d 22 68 74 74 70 3a 2f |.<A HREF="http:/| 00000440 2f 77 77 77 2e 65 6e 67 2e 63 61 6d 2e 61 63 2e |/www.eng.cam.ac.| 00000450 75 6b 2f 65 78 74 65 72 6e 61 6c 2f 62 69 6f 2f |uk/external/bio/| 00000460 22 3e 0a 42 72 69 74 69 73 68 20 49 6e 66 6f 72 |">.British Infor| 00000470 6d 61 74 69 63 73 20 4f 6c 79 6d 70 69 61 64 3c |matics Olympiad<| 00000480 2f 41 3e 2e 0a 3c 70 3e 3c 48 52 3e 0a 3c 70 3e |/A>..<p><HR>.<p>| 00000490 53 6f 6c 75 74 69 6f 6e 73 20 74 6f 20 74 68 65 |Solutions to the| 000004a0 73 65 20 70 72 6f 62 6c 65 6d 73 20 63 61 6e 20 |se problems can | 000004b0 62 65 20 66 6f 75 6e 64 20 69 6e 0a 3c 4b 42 44 |be found in.<KBD| 000004c0 3e 3c 41 20 48 52 45 46 3d 22 73 61 6d 70 6c 65 |><A HREF="sample| 000004d0 73 2e 70 61 73 22 3e 73 61 6d 70 6c 65 73 2e 70 |s.pas">samples.p| 000004e0 61 73 3c 2f 41 3e 3c 2f 4b 42 44 3e 2e 3c 70 3e |as</A></KBD>.<p>| 000004f0 3c 48 52 3e 0a 0a 0a 3c 48 32 3e 31 2e 20 50 72 |<HR>...<H2>1. Pr| 00000500 69 6d 65 20 4e 75 6d 62 65 72 73 3c 2f 48 32 3e |ime Numbers</H2>| 00000510 0a 0a 41 20 70 72 69 6d 65 20 6e 75 6d 62 65 72 |..A prime number| 00000520 20 69 73 20 64 65 66 69 6e 65 64 20 61 73 20 61 | is defined as a| 00000530 6e 79 20 69 6e 74 65 67 65 72 20 67 72 65 61 74 |ny integer great| 00000540 65 72 20 74 68 61 6e 20 6f 6e 65 20 77 68 69 63 |er than one whic| 00000550 68 0a 63 6f 6e 74 61 69 6e 73 20 6e 6f 20 66 61 |h.contains no fa| 00000560 63 74 6f 72 73 20 6f 74 68 65 72 20 74 68 61 6e |ctors other than| 00000570 20 6f 6e 65 20 61 6e 64 20 69 74 73 65 6c 66 20 | one and itself | 00000580 2d 20 74 68 61 74 20 69 73 2c 20 69 66 20 74 68 |- that is, if th| 00000590 65 72 65 0a 69 73 20 6e 6f 20 6e 75 6d 62 65 72 |ere.is no number| 000005a0 20 62 65 74 77 65 65 6e 20 28 61 6e 64 20 6e 6f | between (and no| 000005b0 74 20 69 6e 63 6c 75 64 69 6e 67 29 0a 31 20 61 |t including).1 a| 000005c0 6e 64 20 4e 20 77 68 69 63 68 20 63 61 6e 20 64 |nd N which can d| 000005d0 69 76 69 64 65 20 4e 20 77 69 74 68 20 6e 6f 20 |ivide N with no | 000005e0 72 65 6d 61 69 6e 64 65 72 2c 0a 74 68 65 6e 20 |remainder,.then | 000005f0 4e 20 69 73 20 70 72 69 6d 65 2e 0a 3c 70 3e 0a |N is prime..<p>.| 00000600 59 6f 75 72 20 70 72 6f 67 72 61 6d 20 73 68 6f |Your program sho| 00000610 75 6c 64 20 61 73 6b 20 66 6f 72 20 61 20 6d 61 |uld ask for a ma| 00000620 78 69 6d 75 6d 20 6e 75 6d 62 65 72 2c 20 4d 2c |ximum number, M,| 00000630 20 61 6e 64 20 73 65 61 72 63 68 0a 66 6f 72 20 | and search.for | 00000640 61 6e 64 20 70 72 69 6e 74 20 61 6c 6c 20 70 72 |and print all pr| 00000650 69 6d 65 20 6e 75 6d 62 65 72 73 20 69 6e 20 74 |ime numbers in t| 00000660 68 65 20 72 61 6e 67 65 20 32 2e 2e 4d 2e 20 20 |he range 2..M. | 00000670 59 6f 75 20 73 68 6f 75 6c 64 0a 61 6c 73 6f 20 |You should.also | 00000680 64 69 73 70 6c 61 79 20 74 68 65 20 6e 75 6d 62 |display the numb| 00000690 65 72 20 6f 66 20 70 72 69 6d 65 20 6e 75 6d 62 |er of prime numb| 000006a0 65 72 73 20 66 6f 75 6e 64 2e 20 20 4d 20 77 69 |ers found. M wi| 000006b0 6c 6c 20 6e 6f 74 0a 62 65 20 67 72 65 61 74 65 |ll not.be greate| 000006c0 72 20 74 68 61 6e 20 32 30 30 30 2e 0a 0a 3c 48 |r than 2000...<H| 000006d0 33 3e 53 61 6d 70 6c 65 20 4f 75 74 70 75 74 20 |3>Sample Output | 000006e0 66 6f 72 20 50 72 6f 62 6c 65 6d 20 31 3c 2f 48 |for Problem 1</H| 000006f0 33 3e 0a 3c 70 3e 0a 4d 61 78 69 6d 75 6d 20 6e |3>.<p>.Maximum n| 00000700 75 6d 62 65 72 20 74 6f 20 74 65 73 74 3f 20 32 |umber to test? 2| 00000710 31 3c 70 3e 0a 54 68 65 20 66 6f 6c 6c 6f 77 69 |1<p>.The followi| 00000720 6e 67 20 6e 75 6d 62 65 72 73 20 62 65 74 77 65 |ng numbers betwe| 00000730 65 6e 20 32 20 61 6e 64 20 32 31 20 61 72 65 20 |en 2 and 21 are | 00000740 70 72 69 6d 65 3a 3c 70 3e 0a 32 20 33 20 35 20 |prime:<p>.2 3 5 | 00000750 37 20 31 31 20 31 33 20 31 37 20 31 39 3c 70 3e |7 11 13 17 19<p>| 00000760 0a 41 20 74 6f 74 61 6c 20 6f 66 20 38 20 70 72 |.A total of 8 pr| 00000770 69 6d 65 20 6e 75 6d 62 65 72 73 20 77 65 72 65 |ime numbers were| 00000780 20 66 6f 75 6e 64 20 69 6e 20 74 68 69 73 20 72 | found in this r| 00000790 61 6e 67 65 2e 3c 70 3e 0a 0a 3c 48 32 3e 32 2e |ange.<p>..<H2>2.| 000007a0 20 57 6f 72 64 20 43 6f 75 6e 74 3c 2f 48 32 3e | Word Count</H2>| 000007b0 0a 0a 59 6f 75 20 73 68 6f 75 6c 64 20 77 72 69 |..You should wri| 000007c0 74 65 20 61 20 70 72 6f 67 72 61 6d 20 77 68 69 |te a program whi| 000007d0 63 68 20 61 73 6b 73 20 66 6f 72 20 74 68 65 20 |ch asks for the | 000007e0 6e 61 6d 65 20 6f 66 20 61 20 66 69 6c 65 0a 61 |name of a file.a| 000007f0 6e 64 20 74 68 65 6e 20 63 6f 75 6e 74 73 20 74 |nd then counts t| 00000800 68 65 20 6e 75 6d 62 65 72 20 6f 66 20 77 6f 72 |he number of wor| 00000810 64 73 20 69 6e 20 74 68 65 20 66 69 6c 65 2e 20 |ds in the file. | 00000820 20 41 20 77 6f 72 64 20 69 73 0a 64 65 66 69 6e | A word is.defin| 00000830 65 64 20 61 73 20 61 6e 79 20 73 65 71 75 65 6e |ed as any sequen| 00000840 63 65 20 6f 66 20 73 79 6d 62 6f 6c 73 20 73 65 |ce of symbols se| 00000850 70 61 72 61 74 65 64 20 62 79 20 61 6e 79 20 63 |parated by any c| 00000860 6f 6d 62 69 6e 61 74 69 6f 6e 20 6f 66 0a 73 70 |ombination of.sp| 00000870 61 63 65 20 63 68 61 72 61 63 74 65 72 73 20 61 |ace characters a| 00000880 6e 64 2f 6f 72 20 6c 69 6e 65 20 62 72 65 61 6b |nd/or line break| 00000890 73 2e 0a 3c 70 3e 0a 54 68 65 20 66 69 6c 65 20 |s..<p>.The file | 000008a0 77 69 6c 6c 20 6e 6f 74 20 63 6f 6e 74 61 69 6e |will not contain| 000008b0 20 6c 69 6e 65 73 20 6d 6f 72 65 20 74 68 61 6e | lines more than| 000008c0 20 31 32 37 0a 63 68 61 72 61 63 74 65 72 73 20 | 127.characters | 000008d0 6c 6f 6e 67 20 61 6e 64 20 77 69 6c 6c 20 68 61 |long and will ha| 000008e0 76 65 20 61 20 6d 61 78 69 6d 75 6d 20 6f 66 20 |ve a maximum of | 000008f0 32 30 2c 30 30 30 20 77 6f 72 64 73 2e 0a 3c 70 |20,000 words..<p| 00000900 3e 0a 28 54 61 6b 65 20 63 61 72 65 20 77 68 65 |>.(Take care whe| 00000910 6e 20 63 72 65 61 74 69 6e 67 20 61 20 74 65 73 |n creating a tes| 00000920 74 20 66 69 6c 65 20 74 6f 20 6d 61 6b 65 20 73 |t file to make s| 00000930 75 72 65 20 69 74 20 65 6e 64 73 0a 77 69 74 68 |ure it ends.with| 00000940 20 61 74 20 6c 65 61 73 74 20 6f 6e 65 20 62 6c | at least one bl| 00000950 61 6e 6b 20 6c 69 6e 65 2c 20 6f 74 68 65 72 77 |ank line, otherw| 00000960 69 73 65 20 69 74 20 6d 61 79 20 62 65 20 69 67 |ise it may be ig| 00000970 6e 6f 72 65 64 0a 62 79 20 79 6f 75 72 20 70 72 |nored.by your pr| 00000980 6f 67 72 61 6d 6d 69 6e 67 20 6c 61 6e 67 75 61 |ogramming langua| 00000990 67 65 2e 29 0a 3c 70 3e 0a 3c 48 33 3e 53 61 6d |ge.).<p>.<H3>Sam| 000009a0 70 6c 65 20 66 69 6c 65 20 66 6f 72 20 50 72 6f |ple file for Pro| 000009b0 62 6c 65 6d 20 32 3a 20 73 61 6d 70 6c 65 2e 66 |blem 2: sample.f| 000009c0 69 6c 3c 2f 48 33 3e 0a 0a 54 68 65 20 63 61 74 |il</H3>..The cat| 000009d0 20 73 61 74 20 6f 6e 20 74 68 65 20 6d 61 74 2e | sat on the mat.| 000009e0 3c 70 3e 0a 54 68 65 20 63 6f 77 20 6a 75 6d 70 |<p>.The cow jump| 000009f0 65 64 20 6f 76 65 72 20 74 68 65 20 6d 6f 6f 6e |ed over the moon| 00000a00 2e 3c 70 3e 0a 53 68 65 20 73 65 6c 6c 73 20 73 |.<p>.She sells s| 00000a10 65 61 20 73 68 65 6c 6c 73 20 6f 6e 20 74 68 65 |ea shells on the| 00000a20 20 73 65 61 20 73 68 6f 72 65 2e 3c 70 3e 0a 0a | sea shore.<p>..| 00000a30 3c 48 33 3e 53 61 6d 70 6c 65 20 4f 75 74 70 75 |<H3>Sample Outpu| 00000a40 74 20 66 6f 72 20 50 72 6f 62 6c 65 6d 20 32 3c |t for Problem 2<| 00000a50 2f 48 33 3e 0a 0a 4e 61 6d 65 20 6f 66 20 66 69 |/H3>..Name of fi| 00000a60 6c 65 20 66 6f 72 20 77 6f 72 64 20 63 6f 75 6e |le for word coun| 00000a70 74 3f 20 73 61 6d 70 6c 65 2e 66 69 6c 3c 70 3e |t? sample.fil<p>| 00000a80 0a 54 68 65 20 66 69 6c 65 20 73 61 6d 70 6c 65 |.The file sample| 00000a90 2e 66 69 6c 20 63 6f 6e 74 61 69 6e 73 20 32 30 |.fil contains 20| 00000aa0 20 77 6f 72 64 73 2e 3c 70 3e 0a 0a 3c 48 32 3e | words.<p>..<H2>| 00000ab0 33 2e 20 42 75 62 62 6c 65 20 73 6f 72 74 3c 2f |3. Bubble sort</| 00000ac0 48 32 3e 0a 0a 54 6f 20 73 6f 6c 76 65 20 74 68 |H2>..To solve th| 00000ad0 69 73 20 70 72 6f 62 6c 65 6d 20 79 6f 75 20 73 |is problem you s| 00000ae0 68 6f 75 6c 64 20 77 72 69 74 65 20 61 20 70 72 |hould write a pr| 00000af0 6f 67 72 61 6d 20 74 6f 20 73 6f 72 74 0a 6e 75 |ogram to sort.nu| 00000b00 6d 62 65 72 73 2e 20 20 49 74 20 73 68 6f 75 6c |mbers. It shoul| 00000b10 64 20 72 65 61 64 20 69 6e 20 69 6e 74 65 67 65 |d read in intege| 00000b20 72 73 20 66 72 6f 6d 20 74 68 65 20 6b 65 79 62 |rs from the keyb| 00000b30 6f 61 72 64 2c 0a 65 6e 64 69 6e 67 20 77 69 74 |oard,.ending wit| 00000b40 68 20 61 6e 64 20 69 67 6e 6f 72 69 6e 67 20 74 |h and ignoring t| 00000b50 68 65 20 6e 75 6d 62 65 72 20 2d 39 39 39 2c 20 |he number -999, | 00000b60 73 6f 72 74 20 74 68 65 6d 20 61 6e 64 0a 70 72 |sort them and.pr| 00000b70 69 6e 74 20 74 68 65 6d 20 69 6e 20 6f 72 64 65 |int them in orde| 00000b80 72 2c 20 73 6d 61 6c 6c 65 73 74 20 66 69 72 73 |r, smallest firs| 00000b90 74 2e 20 20 54 68 65 72 65 20 77 69 6c 6c 20 62 |t. There will b| 00000ba0 65 0a 62 65 74 77 65 65 6e 20 32 20 61 6e 64 20 |e.between 2 and | 00000bb0 32 30 20 6e 75 6d 62 65 72 73 20 74 6f 20 62 65 |20 numbers to be| 00000bc0 20 73 6f 72 74 65 64 2e 0a 3c 70 3e 0a 59 6f 75 | sorted..<p>.You| 00000bd0 20 6d 61 79 20 75 73 65 20 61 20 73 69 6d 70 6c | may use a simpl| 00000be0 65 20 73 6f 72 74 69 6e 67 20 6d 65 74 68 6f 64 |e sorting method| 00000bf0 20 63 61 6c 6c 65 64 20 62 75 62 62 6c 65 73 6f | called bubbleso| 00000c00 72 74 2e 0a 54 68 69 73 20 73 69 6d 70 6c 79 20 |rt..This simply | 00000c10 63 6f 6d 70 61 72 65 73 20 65 61 63 68 20 6e 75 |compares each nu| 00000c20 6d 62 65 72 20 77 69 74 68 20 69 74 73 20 6e 65 |mber with its ne| 00000c30 78 74 20 6e 65 69 67 68 62 6f 75 72 0a 69 6e 20 |xt neighbour.in | 00000c40 74 75 72 6e 2c 20 73 77 61 70 70 69 6e 67 20 74 |turn, swapping t| 00000c50 68 65 6d 20 69 66 20 74 68 65 79 20 61 72 65 20 |hem if they are | 00000c60 6f 75 74 20 6f 66 20 73 65 71 75 65 6e 63 65 2c |out of sequence,| 00000c70 20 61 6e 64 0a 72 65 70 65 61 74 65 64 6c 79 20 | and.repeatedly | 00000c80 67 6f 65 73 20 74 68 72 6f 75 67 68 20 74 68 65 |goes through the| 00000c90 20 64 61 74 61 20 75 6e 74 69 6c 20 6e 6f 20 6d | data until no m| 00000ca0 6f 72 65 20 63 68 61 6e 67 65 73 0a 63 61 6e 20 |ore changes.can | 00000cb0 62 65 20 6d 61 64 65 2e 0a 3c 70 3e 0a 3c 48 33 |be made..<p>.<H3| 00000cc0 3e 53 61 6d 70 6c 65 20 4f 75 74 70 75 74 20 66 |>Sample Output f| 00000cd0 6f 72 20 50 72 6f 62 6c 65 6d 20 33 3c 2f 48 33 |or Problem 3</H3| 00000ce0 3e 0a 0a 54 79 70 65 20 69 6e 20 75 70 20 74 6f |>..Type in up to| 00000cf0 20 32 30 20 6e 75 6d 62 65 72 73 2c 20 65 6e 64 | 20 numbers, end| 00000d00 69 6e 67 20 77 69 74 68 20 2d 39 39 39 3a 3c 70 |ing with -999:<p| 00000d10 3e 0a 32 33 3c 70 3e 0a 31 32 3c 70 3e 0a 34 35 |>.23<p>.12<p>.45| 00000d20 3c 70 3e 0a 33 32 3c 70 3e 0a 38 3c 70 3e 0a 2d |<p>.32<p>.8<p>.-| 00000d30 31 3c 70 3e 0a 32 3c 70 3e 0a 2d 39 39 39 3c 70 |1<p>.2<p>.-999<p| 00000d40 3e 0a 54 68 65 20 37 20 73 6f 72 74 65 64 20 6e |>.The 7 sorted n| 00000d50 75 6d 62 65 72 73 20 61 72 65 3a 3c 70 3e 0a 2d |umbers are:<p>.-| 00000d60 31 3c 70 3e 0a 32 3c 70 3e 0a 38 3c 70 3e 0a 31 |1<p>.2<p>.8<p>.1| 00000d70 32 3c 70 3e 0a 32 33 3c 70 3e 0a 33 32 3c 70 3e |2<p>.23<p>.32<p>| 00000d80 0a 34 35 3c 70 3e 0a 3c 48 32 3e 45 6e 64 20 6f |.45<p>.<H2>End o| 00000d90 66 20 42 49 4f 20 31 39 39 35 20 53 61 6d 70 6c |f BIO 1995 Sampl| 00000da0 65 20 50 72 6f 62 6c 65 6d 73 3c 2f 48 32 3e 0a |e Problems</H2>.| 00000db0 3c 48 52 3e 0a 3c 48 32 3e 48 6f 77 20 74 6f 20 |<HR>.<H2>How to | 00000dc0 45 6e 74 65 72 20 74 68 65 0a 3c 41 20 48 52 45 |Enter the.<A HRE| 00000dd0 46 3d 22 68 74 74 70 3a 2f 2f 77 77 77 2e 65 6e |F="http://www.en| 00000de0 67 2e 63 61 6d 2e 61 63 2e 75 6b 2f 65 78 74 65 |g.cam.ac.uk/exte| 00000df0 72 6e 61 6c 2f 62 69 6f 2f 22 3e 0a 42 72 69 74 |rnal/bio/">.Brit| 00000e00 69 73 68 20 49 6e 66 6f 72 6d 61 74 69 63 73 20 |ish Informatics | 00000e10 4f 6c 79 6d 70 69 61 64 3c 2f 41 3e 3c 2f 48 32 |Olympiad</A></H2| 00000e20 3e 0a 0a 49 66 20 79 6f 75 20 68 61 76 65 20 73 |>..If you have s| 00000e30 75 63 63 65 73 73 66 75 6c 6c 79 20 63 6f 6d 70 |uccessfully comp| 00000e40 6c 65 74 65 64 20 61 6e 79 20 6f 66 20 74 68 65 |leted any of the| 00000e50 73 65 20 70 72 6f 62 6c 65 6d 73 2c 0a 79 6f 75 |se problems,.you| 00000e60 20 73 68 6f 75 6c 64 20 62 65 20 61 62 6c 65 20 | should be able | 00000e70 74 6f 20 64 6f 20 77 65 6c 6c 20 69 6e 20 74 68 |to do well in th| 00000e80 65 20 42 72 69 74 69 73 68 20 49 6e 66 6f 72 6d |e British Inform| 00000e90 61 74 69 63 73 20 4f 6c 79 6d 70 69 61 64 0a 52 |atics Olympiad.R| 00000ea0 6f 75 6e 64 20 4f 6e 65 2e 0a 54 68 69 73 20 63 |ound One..This c| 00000eb0 6f 6d 70 65 74 69 74 69 6f 6e 20 69 73 20 6f 70 |ompetition is op| 00000ec0 65 6e 20 74 6f 20 61 6c 6c 20 73 74 75 64 65 6e |en to all studen| 00000ed0 74 73 20 69 6e 20 73 65 63 6f 6e 64 61 72 79 20 |ts in secondary | 00000ee0 65 64 75 63 61 74 69 6f 6e 0a 77 68 6f 20 77 69 |education.who wi| 00000ef0 6c 6c 20 62 65 20 75 6e 64 65 72 20 31 39 20 79 |ll be under 19 y| 00000f00 65 61 72 73 20 6f 6c 64 20 6f 6e 20 32 36 20 4a |ears old on 26 J| 00000f10 75 6e 65 2c 20 31 39 39 35 2e 0a 3c 70 3e 0a 50 |une, 1995..<p>.P| 00000f20 72 69 7a 65 73 20 61 6e 64 20 63 65 72 74 69 66 |rizes and certif| 00000f30 69 63 61 74 65 73 20 77 69 6c 6c 20 62 65 20 61 |icates will be a| 00000f40 77 61 72 64 65 64 20 74 6f 20 61 6c 6c 20 73 74 |warded to all st| 00000f50 75 64 65 6e 74 73 20 77 68 6f 20 64 6f 20 77 65 |udents who do we| 00000f60 6c 6c 20 69 6e 0a 74 68 65 20 42 49 4f 2e 20 20 |ll in.the BIO. | 00000f70 54 68 65 20 74 6f 70 20 31 30 2d 31 35 20 77 69 |The top 10-15 wi| 00000f80 6c 6c 20 62 65 20 69 6e 76 69 74 65 64 20 74 6f |ll be invited to| 00000f90 20 61 74 74 65 6e 64 20 74 68 65 20 73 65 63 6f | attend the seco| 00000fa0 6e 64 20 72 6f 75 6e 64 0a 61 6e 64 20 6d 61 79 |nd round.and may| 00000fb0 20 77 69 6e 20 61 20 70 6c 61 63 65 20 6f 6e 20 | win a place on | 00000fc0 74 68 65 20 74 65 61 6d 20 74 6f 20 72 65 70 72 |the team to repr| 00000fd0 65 73 65 6e 74 20 47 72 65 61 74 20 42 72 69 74 |esent Great Brit| 00000fe0 61 69 6e 20 61 74 20 74 68 65 0a 70 72 65 73 74 |ain at the.prest| 00000ff0 69 67 69 6f 75 73 20 49 6e 74 65 72 6e 61 74 69 |igious Internati| 00001000 6f 6e 61 6c 20 4f 6c 79 6d 70 69 61 64 20 69 6e |onal Olympiad in| 00001010 20 49 6e 66 6f 72 6d 61 74 69 63 73 2c 20 77 68 | Informatics, wh| 00001020 69 63 68 20 69 73 20 62 65 69 6e 67 20 68 65 6c |ich is being hel| 00001030 64 0a 69 6e 20 45 69 6e 64 68 6f 76 65 6e 20 69 |d.in Eindhoven i| 00001040 6e 20 74 68 65 20 4e 65 74 68 65 72 6c 61 6e 64 |n the Netherland| 00001050 73 20 66 72 6f 6d 20 32 36 20 4a 75 6e 65 20 74 |s from 26 June t| 00001060 6f 20 33 20 4a 75 6c 79 2c 20 31 39 39 35 2e 0a |o 3 July, 1995..| 00001070 3c 70 3e 0a 54 6f 20 65 6e 74 65 72 20 74 68 65 |<p>.To enter the| 00001080 20 42 72 69 74 69 73 68 20 49 6e 66 6f 72 6d 61 | British Informa| 00001090 74 69 63 73 20 4f 6c 79 6d 70 69 61 64 2c 20 79 |tics Olympiad, y| 000010a0 6f 75 72 20 74 65 61 63 68 65 72 20 73 68 6f 75 |our teacher shou| 000010b0 6c 64 20 77 72 69 74 65 20 74 6f 0a 3c 70 3e 0a |ld write to.<p>.| 000010c0 54 68 65 20 42 72 69 74 69 73 68 20 49 6e 66 6f |The British Info| 000010d0 72 6d 61 74 69 63 73 20 4f 6c 79 6d 70 69 61 64 |rmatics Olympiad| 000010e0 3c 42 52 3e 0a 41 6e 74 6f 6e 79 20 52 69 78 2c |<BR>.Antony Rix,| 000010f0 20 43 68 72 69 73 74 27 73 20 43 6f 6c 6c 65 67 | Christ's Colleg| 00001100 65 2c 20 43 61 6d 62 72 69 64 67 65 20 43 42 32 |e, Cambridge CB2| 00001110 20 33 42 55 3c 70 3e 0a 0a 65 6e 63 6c 6f 73 69 | 3BU<p>..enclosi| 00001120 6e 67 20 61 20 35 37 70 20 53 2e 41 2e 45 2e 20 |ng a 57p S.A.E. | 00001130 20 54 68 65 20 63 6c 6f 73 69 6e 67 20 64 61 74 | The closing dat| 00001140 65 20 66 6f 72 20 65 6e 74 72 69 65 73 20 69 73 |e for entries is| 00001150 20 32 39 20 41 70 72 69 6c 2c 20 31 39 39 35 0a | 29 April, 1995.| 00001160 61 6e 64 20 73 6f 6c 75 74 69 6f 6e 73 20 66 6f |and solutions fo| 00001170 72 20 74 68 65 20 66 69 72 73 74 20 72 6f 75 6e |r the first roun| 00001180 64 20 6f 66 20 74 68 65 20 42 72 69 74 69 73 68 |d of the British| 00001190 20 49 6e 66 6f 72 6d 61 74 69 63 73 20 4f 6c 79 | Informatics Oly| 000011a0 6d 70 69 61 64 0a 6d 75 73 74 20 62 65 20 72 65 |mpiad.must be re| 000011b0 63 65 69 76 65 64 20 62 79 20 37 20 4d 61 79 2c |ceived by 7 May,| 000011c0 20 31 39 39 35 2e 0a 3c 70 3e 0a 3c 48 52 3e 0a | 1995..<p>.<HR>.| 000011d0 3c 41 44 44 52 45 53 53 3e 0a 3c 45 4d 3e 0a 41 |<ADDRESS>.<EM>.A| 000011e0 6e 74 6f 6e 79 20 52 69 78 3c 2f 45 4d 3e 3c 2f |ntony Rix</EM></| 000011f0 41 44 44 52 45 53 53 3e 0a |ADDRESS>.| 000011f9