I have this hw that ask for a program that will ask the user to input integers and sort them in ascending order and write the occurrences for each.
This is what i've done so far. I don't know how to put same elements in one array.
here is the sample form the book:
Sample input: 9 17 9 8 9 5 5
Output:
N count
3 1
5 2
8 1
9 3
17 1
a bad habit the book teaches you is using single letters for Int, try using words that describe what they are for
N=sizeofarray in your for loop it is usually better to declare your variable there instead of making them global so maybe like this
1 2 3
for (int i=0; i<a; i++){
your code
}
then when the for loop is done the variable is release. and keeps your memory cleaner.
your elements are in one array N[a] your N[i] and N[j] are just positions in your array N[ ] N[a] is just the size or how many spots there are in your array the array is N[ ].