Click here to Skip to main content
16,005,121 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionPrintout image? Pin
Larsson22-Sep-04 3:14
Larsson22-Sep-04 3:14 
QuestionEnvironment problem perhaps? Pin
mcgahanfl22-Sep-04 2:59
mcgahanfl22-Sep-04 2:59 
AnswerRe: Environment problem perhaps? Pin
mcgahanfl22-Sep-04 8:39
mcgahanfl22-Sep-04 8:39 
GeneralMenus - Setting a check mark Pin
mcsherry22-Sep-04 2:52
mcsherry22-Sep-04 2:52 
GeneralRe: Menus - Setting a check mark Pin
vcplusplus22-Sep-04 3:14
vcplusplus22-Sep-04 3:14 
GeneralRe: Menus - Setting a check mark Pin
mcsherry22-Sep-04 3:17
mcsherry22-Sep-04 3:17 
GeneralRe: Menus - Setting a check mark Pin
mcsherry22-Sep-04 4:34
mcsherry22-Sep-04 4:34 
Generalfunction problem Pin
ISUstudent22-Sep-04 2:51
ISUstudent22-Sep-04 2:51 
Ok...I solved my previous questions.

This question deals with a deleteItem function that is to delete an item from an array. And I am passing a sorted array, its size, and the target element...this is what I have so far...






#include
#include
using namespace std;

template
void sortArray(T arr[], int size);

template
void searchArray(T arr[], int size, T target);

template
void deleteItem(T arr[], int &size, T target);

template
void printArray(T arr[], int size);

int main()
{

int size;
int target;
int arr[10] = {9,8,7,6,5,1,2,3,0,4};











system ("pause");
}

template
void sortArray(T arr[], int size)
{
int smallest;
T temp;
for(int i=0; i {
smallest = i;

for(int j =i+1; j {
if(arr[j] < arr[j-1])
smallest = j;
}

temp = arr[j];
arr[j] = arr[j-1];
arr[j-1] = temp;
}

}



template
void searchArray(T arr[], int size, T target)
{
int size;
int low = 0;
int high = size -1;
int mid = (low + high)/2;
int target;

bool found = flase;
do
{
if(target == arr[mid])
found = true;

else if(target < arry[mid])
high = mid-1; //looks below mid

else
low = mid +1;

if(!found)
{
mid = (low + high)/2;
}

}while (high >= low && !found)

//WHAT DO I RETURN???


}


template
void deleteItem(T arr[], int &size, T target)//only function with pass by reference
{

//PROBLEM HERE!!!!!!?????????


}



template
void printArray(T arr[], int size)
{
for(int i=0; i {
cout << arr[i] << " ";
}
}












Can anybody help me with the delete item method...I'M SO LOST!!!!!

THANK YOU FOR YOUR TIME!

Jason
QuestionWM_HOTKEY how to notice a global hotkey release (keyup)? Pin
Member 134487422-Sep-04 2:40
Member 134487422-Sep-04 2:40 
AnswerRe: WM_HOTKEY how to notice a global hotkey release (keyup)? Pin
Anonymous22-Sep-04 3:41
Anonymous22-Sep-04 3:41 
GeneralRe: WM_HOTKEY how to notice a global hotkey release (keyup)? Pin
Member 134487422-Sep-04 5:19
Member 134487422-Sep-04 5:19 
GeneralDetecting a pixel on the SDI Pin
jw8122-Sep-04 2:14
jw8122-Sep-04 2:14 
GeneralRe: Detecting a pixel on the SDI Pin
KaЯl22-Sep-04 5:04
KaЯl22-Sep-04 5:04 
GeneralRe: Detecting a pixel on the SDI Pin
jw8122-Sep-04 19:32
jw8122-Sep-04 19:32 
Generalnumber of bits in a byte (char) Pin
peterworth22-Sep-04 1:31
peterworth22-Sep-04 1:31 
GeneralRe: number of bits in a byte (char) Pin
Henry miller22-Sep-04 3:24
Henry miller22-Sep-04 3:24 
Generalincomin connection dialog Pin
mark18222-Sep-04 1:30
mark18222-Sep-04 1:30 
Generalsending voice over network Pin
pardis22-Sep-04 1:28
pardis22-Sep-04 1:28 
GeneralRe: sending voice over network Pin
Alexander M.,22-Sep-04 10:34
Alexander M.,22-Sep-04 10:34 
GeneralHelp required on search through a list of files. Pin
lisa.hao22-Sep-04 1:24
lisa.hao22-Sep-04 1:24 
GeneralVMR9 Pin
Dani7722-Sep-04 0:32
Dani7722-Sep-04 0:32 
GeneralListBox controlls Pin
Larsson22-Sep-04 0:23
Larsson22-Sep-04 0:23 
Generalbacking and restoring registry Pin
Monty222-Sep-04 0:23
Monty222-Sep-04 0:23 
GeneralRe: backing and restoring registry Pin
Mike Dimmick22-Sep-04 0:40
Mike Dimmick22-Sep-04 0:40 
GeneralRe: backing and restoring registry Pin
Monty222-Sep-04 0:56
Monty222-Sep-04 0:56 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.