V
viuxrluxvbbc
Hi im trying to write a program that will read in numbers and display
them in ascending order along with a count of how many times it
repeats. i got the numerical order portion done but cant figure out the
other part. i keep on getting a wrong number
please help
#include <iostream>
using namespace std;
int main()
{
int numbers[4] = {8,3,8,5};
int temp, counter, index, see, times, appears;
for (counter = 0; counter < 4; counter++)
{
for (index = 0; index < 4 - counter; index++)
{
if (numbers[index] > numbers[index + 1])
{
temp = numbers[index];
numbers[index] = numbers[index+1];
numbers[index+1] = temp;
}
}
}
for (int times = 0; times < 4 ; times++)
{
if (numbers[times] !=8)
appears++;
else
appears = 0;
}
cout << appears; //wrong
for (see = 0; see < 4; see++)
{
cout << numbers[see] << " ";
}
them in ascending order along with a count of how many times it
repeats. i got the numerical order portion done but cant figure out the
other part. i keep on getting a wrong number
please help
#include <iostream>
using namespace std;
int main()
{
int numbers[4] = {8,3,8,5};
int temp, counter, index, see, times, appears;
for (counter = 0; counter < 4; counter++)
{
for (index = 0; index < 4 - counter; index++)
{
if (numbers[index] > numbers[index + 1])
{
temp = numbers[index];
numbers[index] = numbers[index+1];
numbers[index+1] = temp;
}
}
}
for (int times = 0; times < 4 ; times++)
{
if (numbers[times] !=8)
appears++;
else
appears = 0;
}
cout << appears; //wrong
for (see = 0; see < 4; see++)
{
cout << numbers[see] << " ";
}