469,890 Members | 1,416 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,890 developers. It's quick & easy.

Need hlep to delete array only because all function is ok (inser, sort andsearch)

Need hlep to delete array only because all function is ok (inser, sort andsearch)

#include <iostream.h>

//functions prototype
void Insert(int[],int);
void Delete(int[],int);
int Search(int[],int);
void Sort(int[],int);

int n=0,i=0,location;
bool found;

int main()

int grades[10],i,g;
cout<<"Enter a new grade ";
//cout <<"grades["<<i<<"]="<<grades[i]<<endl;
} // end for loop

// functions definitions

//print out the values of the array
cout <<grades[i]<<endl;


/* for(i=0;i<3;i++){
cout <<grades[i]<<endl;

return 0;
} // end main

// functions
void Insert(int a[],int item){

void Delete (int a[],int item){
if (found==true){
cout <<" out of search, found in place"<<location<<endl;
for (int k=location;k=3;k++){ //////here is to check//////
cout <<"not found!!";

}// end delete

int Search(int a[],int item){
// Assumption: Whenever it finds the value, it stops
for (int i=0;i<n;i++){
if (a[i]==item){
cout <<"inside seearch,found in place "<<i<<endl;
location= i;
return location;

}//end of search

void Sort(int a[], int length)
int count,SI, MI,temp;
for(count = 0;count<length-1;count++)
MI = count;
for(SI = count + 1; SI <length; SI++)
if(a[SI] < a[MI]) MI = SI;

// swap the grades
temp = a[MI];
a[MI] = a[count];
a[count] = temp;

} // end of sort
Nov 11 '06 #1
1 1408
1,510 Expert 1GB
the removal of the element at location in delete() was faulty, try
Expand|Select|Wrap|Line Numbers
  1. void Delete (int a[],int item){
  2. Search(a,item);
  3. if (found==true){
  4. cout <<" out of search, found in place"<<location<<endl;
  5. for (int k=location;k+1<n;k++){ //////here is to check//////
  6. a[k]=a[k+1];
  7. }
  8. n=n-1;
  9. }
  10. else
  11. cout <<"not found!!";
  12. }// end delete
Nov 11 '06 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

7 posts views Thread by Christopher Jeris | last post: by
3 posts views Thread by ritchie | last post: by
24 posts views Thread by Michael | last post: by
20 posts views Thread by Martin Jørgensen | last post: by
3 posts views Thread by Milagro | last post: by
4 posts views Thread by Paul David Buchan | last post: by
1 post views Thread by Waqarahmed | last post: by
reply views Thread by Salome Sato | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.