Cassi
2013-05-30 17:32:58 UTC
#include
#include
#include
using namespace std;
void search (char, int, int, int);
int main ()
{
int i = 0;
int SIZE = 0;
char numbers[50];
int tally[50];
int source, num;
char file_name[16];
do
{
cout << "Enter 1 for manual input from keyboard, 2 for reading from a file: ";
cin >> source;
} while (!((source == 1) || (source == 2)));
if (source == 1) // keyboard
{
do
{
cout << "Enter a number (99999 to end): ";
cin >> num;
search (numbers[i], tally[i], num, SIZE);
} while (num != 99999);
}
}
void search (char numbers[], int tally[], int target, int SIZE)
{
int index = 0;
bool found = false;
while ((!found) && (index < SIZE))
{
if (target == numbers[index])
found = true;
else
index++;
}
if (found)
{
tally[index]++;
}
else
{
numbers[SIZE] = target;
tally[SIZE] = 1;
SIZE++;
}
return;
}