# Single-Subscripted Array

Page 1 of 1

## 1 Replies - 734 Views - Last Post: 06 March 2013 - 05:10 PMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'http://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=314541&amp;s=47f050b53a774c666105247c64392195&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #1 ThatBeast

• New D.I.C Head

Reputation: 2
• Posts: 38
• Joined: 16-November 12

# Single-Subscripted Array

Posted 06 March 2013 - 05:01 PM

I have to use a single-subscripted array to solve the following problem. Read in 20 numbers, each of which is between 10 and 100, inclusive. As each number is read, print it only if it is not a duplicate of a number already read. Provide for the "worst case" in which all 20 numbers are different Use the smallest possible array to solve this problem.
The file is contains these numbers:
```12
12
30
12
45
66
78
30
82
19
99
11
11
15
31
18
51
17
12
17
```

How do I do this?

It is supposed to look like this:
The original set of numbers are: 12 12 30 12 45 66 78 30 82 19 99 11 11 15 31 18 51 17 12 17
The different numbers from the set of integers are: 12 30 45 66 78 82 19 99 11 15 31 18 51 17

This post has been edited by ThatBeast: 06 March 2013 - 05:07 PM

Is This A Good Question/Topic? 0

## Replies To: Single-Subscripted Array

### #2 macosxnerd101

• Games, Graphs, and Auctions

Reputation: 11786
• Posts: 44,292
• Joined: 27-December 08

## Re: Single-Subscripted Array

Posted 06 March 2013 - 05:10 PM

If you want to use a fixed size array, an array of size 91 for elements 0-90 would work, then just flag array[element] as true as each element appears. To get a smaller array, you'll want to look into hashing algorithms.
Was This Post Helpful? 0

Page 1 of 1

 .related ul{list-style-type:circle;font-size:12px;font-weight:bold;}.related li{margin-bottom:5px;background-position:left 7px!important;margin-left:-35px;}.related h2{font-size:18px;font-weight:bold;}.related a{color:blue;}