alphabetical order-phillies
Sep 13, 2010 at 7:14pm UTC
ok i made this file called "pphillies.dat"players are listed in hitting order(no pitchers included) first i am trying to make the order in alphabetical order then trying to add, search and then delete chase utley.This is what i got so far and its not working. i called the file phillies bc they were the 2008 champs.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86
#include<fstream>
#include<iostream>
#include<cstring>
using namespace std;
struct pphillies
{
int alphab;
char hitter[25];
int next;
}plist[50];
void insertion(hitter keyname);
void delete (hitter keyname);
void search(hitter keyname);
int main()
{
int p[name];
int i;
int order;
int where;
int whereprev;
int next_hitter;
ifstream fin;
ofstream fout;
fin.open("pphillies.dat" );
fout.open("pphilies_output.dat" );
int n=0;
fin>>hlist[n].hitter;
if (fin.fail()) {
cout << "Error opening stream." << endl;
abort();
while (!fin.eof())
{
hlist[n].alphab = n+1;
n++;
fin>>hlist[n].hitter;
}
cout<<"alphabetical\talphab\thitter name\tnext hitter" <<endl<<endl;
for (int i = 0; hlist[i] != NULL && i < 50; i++) {
cout << n << " " << hlist[i].alphab << " " << hlist[n].hname << endl;
}
return 0;
}
void insertion(hitter keyname)
{
bool found
int where
binsearch(keyname,found,where);
if (found)
{
cout<<keyname<<"on the hitting list" <<where<<endl;
}
else
{
for (i=n;i>=where;i--)
{
hitter[i+1] = hitter[i];
n++;
h[where] = hname;
cout<< hname <<"inserted
in the hitting list" <<where <<endl;
}
}
}
void deletion( hitter keyname, lref & head)
{ bool found, lref where, whereprev;
listsearch (keyname, head, found, where, whereprev);
if (!found)
cout<<keyname<<" not in list insert him so we can be the wolrd champions again" << endl;
else
whereprev->next= where->next;
else
head = where->next;
cout<<keyname<<"deleted from the list" <<
where<<endl:
}}
void search(hitter keyname)
{
while (fin>>keyname)
{
insert keyname;
}
Sep 14, 2010 at 3:50pm UTC
Does the code compile? I can't see where hlist or n are declared.
Topic archived. No new replies allowed.