C#:Assessment Arrays Easy

From Progzoo
Jump to: navigation, search

You can use arrays to solve these problems. In each example your program must read in a file of numbers and output true or false.

For each problem there is a set of test files.

Check 1 to 20

Read in some numbers from 1 to 20.

Change the method check so that it will:

  • print true if all of the numbers from 1 to 20 are present
  • print false otherwise.

You may find the following tutorial useful:

The test files used are: http://progzoo.net/array11.txt

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20

http://progzoo.net/array12.txt

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 17 19 20

http://progzoo.net/array13.txt

1

http://progzoo.net/array14.txt

11 12 13 14 15 16 17 18 19 1 2 3 4 5 6 7 8 9 10 20



[Font] [Default] [Show] [Resize] [History] [Profile]

Palindromes

Read in a list of numbers. Print true if the list of numbers is "palindromic" – that is it reads the same backwards as forwards; print "false" otherwise.

You may assume that there are fewer than 100 numbers in the list.

The test files used are: http://progzoo.net/array15.txt

1 2 2 1

http://progzoo.net/array16.txt

1 2 2 2 2 2 2

http://progzoo.net/array17.txt

1 8 1 6 7 6 1 8 1

http://progzoo.net/array18.txt

200 300 300 299 300 200



[Font] [Default] [Show] [Resize] [History] [Profile]

Duplicates

Read in 20 numbers, each between 1 and 100, inclusive. Print true if the list includes at least one duplicate; print false otherwise.

You will find the frequency list used in the first question useful here.

The test files used are: http://progzoo.net/array19.txt

10

http://progzoo.net/array1a.txt

99 98 1 2 99

http://progzoo.net/array1b.txt

41 74 87 72 36 33 27 39 49 45 23 69 97 20 1 35 60 56 68 6 92 57 25 84 61 5 99 93 90 65 85 8 66 86 89 43 14 62 94 30 75 79 38 44 78 37 91 19 47 71 98 48 83 26 4 76 58 18 29 53 24 70 81 17 82 73 100 2 67 32 28 96 12 59 10 7 15 42 88 50 11 64 63 34 80 77 54 22 95 9 52 21 55 40 31 3 16 46 51

http://progzoo.net/array1c.txt

13 41 74 77 72 36 33 27 39 49 45 23 69 97 20 1 35 60 56 68 6 92 57 25 84 61 5 99 93 90 65 85 8 66 86 89 43 14 62 94 30 75 79 38 44 78 37 91 19 47 71 98 48 83 26 4 76 58 18 29 53 24 70 81 17 82 73 100 2 67 32 28 96 12 59 10 7 15 42 88 50 11 64 63 34 80 77 54 22 95 9 52 21 55 40 31 3 16 46 51


[Font] [Default] [Show] [Resize] [History] [Profile]