ok all, another programming problem that the instructor didnt go over well enough. 3 more posts to follow, 1 with the actual problem, what im trying to do, and lastly my code thus far
1.Search Benchmarks: Write a program that has a sorted array of at least 20 integers. It should call a function that uses the linear search algorithm to locate one of the values. The function should keep a count of the number of comparisons it makes until it finds the value. The program then should call a function that uses the binary search algorithm to locate the same value. It should also keep count of the number of comparisons it makes. Display these values on the screen.
2.Sorting Benchmarks: Write a program that uses two identical arrays of at least 20 integers. It should call a function that uses the bubble sort algorithm to sort one of the arrays in ascending order. The function should keep a count of the number of exchanges it makes. The program then should call a function that uses the selection sort algorithm to sort the other array. It should also keep count of the number of exchanges it makes. Display these values on the screen.
int array {20};
int count;
int number;
int counta;
int countb;
int main ()
{
int array {20} = {9, 18, 27, 36, 54, 45, 99, 63, 108, 72, 3, 6, 12, 15, 21, 24, 30, 33, 39, 42};
cout << " please pick one of the following numbers to search for" << endl;
for (count = 0, count ++, count <20);
{
cout << array {count} << " ";
count = count +1;
}
cin >> number;
int linearsearch (number [], count = 0, count ++);
{
counta = counta+1;
if number = array{count}
{
cout << "the number is in memory position " << count << endl;
cout << "it took " << count << "passes to find it" << endl;
}
else
{
cout " the number is not in memory position " << count << endl;
}
cout <<"the numbers in ascending order are :" << endl;
put your code in the [c0de] [/c0de] tags, makes it a hell of alot easier to read.
1. int array {20}; should be int array[20]
2. same as above.
3.cout << array {count} << " "; should be cout <<array[count] << "" << endl; ( the endl; is not really nessesary)
4. count = count +1; could be changed to just count++ ( not part of ur error just a little somthing)