View Single Post
Old 10-10-2004, 11:04 AM   #7
DeMoN
Regular User
 
Join Date: Jun 2003
Location: Florida
Posts: 5,106
Default

Originally Posted by stracing
int input[100]; /initialise arrays/
int freq[];
int count;

..... /get user input, store in array. you've done this bit/

for (count = 0; count <= "input array size(find the array size)" -1; answer++)
++freq[input[count]];

.../then print out your arrays/
i would do it...

int input[100]; /initialise arrays/
int count;

then do a for loop to add the numbers to the array input, each time you add a number to the array do a count++

once the adding is complete, count should have a value equal to the numbers inputed to the array

now:

int freq[count] = 0; // will make a new array with the size = to count and make them all 0

for (int i=0 ; i < count ; i++) {
for (int j=0 ; j < count ; j++) {
if (input[i] == input[j]) freq[i]++;
}
}

then print array input and arry freq with another loop

for (int i = 0 ; i < count ; i++) {
System.out.println(input[i] + " " + input[j]);
}
__________________
Guess who's Back!
DeMoN is offline   Reply With Quote