コード例 #1
0
ファイル: Lab2.cpp プロジェクト: shravaniraghuram/fslab
int main() {
    int choice,h;
    string key;
    while(1)
    {
            cout<<"1.INSERT 2.SEARCH 3.MODIFY";
            cout<<"enter your choice";
            cin>>choice;
            switch(choice)
            {
            case 1:s.read();
                    s.pack();
                    break;
            case 2:cout<<"enter key";
                    cin>>key;
                    h=s.search(key);
                   cout<<h;
                    break;
            case 3:cout<<"enter the key";
                   cin>>key;
                   s.modify(key);
                   break;
            }
    }

    return 0;
}
コード例 #2
0
ファイル: HW05.cpp プロジェクト: tcl326/DataStruct-Algo
 bool operator() (student first, student second){
     if (first.getName() == _me){
         return true;
     }
     if (second.getName() == _me) {
         return false;
     }
     return first.getName() < second.getName();
 }
コード例 #3
0
ファイル: HmiH_00_P2_Main.cpp プロジェクト: hamdih/2015_2016
void abc(){					// this function will alphabatize all the students after adding them
	int i;
	for(i = 0;i<(count);i++)
	{
	student *now = head;				
	student *next = head->getNext();		// set up pointers to be compared
	string temp1,temp2;
	if(now->getNext() == NULL)
	{
	return;
	}
	else
		{	
		while(now!= NULL)
			{
			temp1 = now->getName();			// set pointers to newly added student
			temp2 = next->getName();
	
		if(temp1 > temp2)			// compare and change
			{
				now->setName(temp2);
				next->setName(temp1);
			
			}
		if(next->getNext() != NULL)
		{
			next = next->getNext();
		}				// keep looping through students to alphabatize
		now = now->getNext();
			}
		}
	}
};
コード例 #4
0
ファイル: main.cpp プロジェクト: hamdih/2015_2016
	void remove(string pick)
	{
	student *now = head;
	if(now !=NULL)
	{
	student *picked = head->getNext();
	}
	student *before = head;
	student *here = NULL;
	while(now!=NULL)
		{

		if(pick == now->getName())
			{
				if(now == head)
					{	
						here = head;
						head = here->getNext();
						delete here;	
						cout<<"Removal Succesfull";
						return;
					}
				before = now->getNext();
				delete now;
				cout<<"Removal Sucessful";
				return;
			}		
			before = now;
			now = now->getNext();	
		

		}
		cout<<"ERROR:Not Found for Removal:"<<pick;
	};
コード例 #5
0
ファイル: main.cpp プロジェクト: hamdih/2015_2016
	int add(string data)
	{
	string nm = data;
	int id = 1;
	student *temp,*temp2;
	id = id+count;
	cout<<"Added: ID "<<setfill('0')<<setw(3)<<id<<" "<<nm;
	temp2 = head;
	temp = new student(nm,id);

	if(count == 0)
	{
	head = tail = temp;
	temp->setNext(NULL);
	count++;
	}	

	else
	{
	tail->setNext(temp);
	tail=temp;
	temp->setNext(NULL);
	count++;

	}
	};
コード例 #6
0
ファイル: VFILE001.CPP プロジェクト: vivin/ancient-code
void check(student &studx, char namex[])
{
		 if(strcmp(namex, studx.name)==0)
		 {
			 studx.accept();
			 usefile.write((char*)&studx, sizeof(studx));
		 }
}
コード例 #7
0
ファイル: HmiH_00_P2_Main.cpp プロジェクト: hamdih/2015_2016
void add(string data)		//this function will add a student to the linked list
	{
	ostringstream oss;
	student *now = head;
	student *end = tail;
	int i;
	while(now != NULL)
	{

			if(now->getName() == data)
			{
			cout<< "DUPLICATE:"<<data<<endl;
			return;
			}
	now = now->getNext();
	}
	
	string nm = data;
	int id = 1;
	student *temp,*temp2;
	id = id+count;
	cout<<"Added: ID "<<setfill('0')<<setw(3)<<id<<" "<<nm<<endl;
	temp2 = head;
	temp = new student(nm,id);
	oss<<"ID00"<<id;
	string temps = oss.str();
	temp->ID = temps;
	
	if(count == 0)
	{
	head = tail = temp;
	temp->setNext(NULL);
	count++;
	}	

	else
	{
	tail->setNext(temp);
	tail=temp;
	temp->setNext(NULL);
	count++;

	}
	
};	
コード例 #8
0
ファイル: HmiH_00_P2_Main.cpp プロジェクト: hamdih/2015_2016
void search(string find) 	// this function will search for a student in the linked list based on their name
	{
		student *now = head;
		student *found = head->getNext();
		student *before = head;
		student *here = NULL;
		while(now != NULL)				
		{
			if( find == now->getName())	// compare student name to searching name
			{
			cout<<"FOUND:"<<""<<now->getName()<<" "<<"UID:"<<now->getID();
			return;
			}
			else
			before = now;
			now= now->getNext();		
	
		}
			cout<<"NOT FOUND:"<<""<<find;
};
コード例 #9
0
ファイル: main.cpp プロジェクト: hamdih/2015_2016
void search(string find)
	{
		student *now = head;
		student *found = head->getNext();
		student *before = head;
		student *here = NULL;
		while(now != NULL)
		{
			if( find == now->getName())
			{
			cout<<"TRUE:"<<""<<now->getName();
			return;
			}
			else
			before = now;
			now= now->getNext();		
	
		}
			cout<<"FALSE:"<<""<<find;
};
コード例 #10
0
ファイル: HmiH_00_P2_Main.cpp プロジェクト: hamdih/2015_2016
void addSpouse(string uid,string spouse1)  //add spouse as person and as spouse to person
	{	
	ostringstream oss;
	student *now = head;
	student *end = tail;
	int i;
	while(now != NULL)
	{

			if(now->getName() == spouse1)
			{
			cout<< "DUPLICATE:"<<spouse1<<endl;
			return;
			}
	now = now->getNext();
	}
	
	string nm = spouse1;
	int id = 1;
	student *temp,*temp2;
	id = id+count;
	cout<<"Added: ID "<<setfill('0')<<setw(3)<<id<<" "<<nm<<endl;
	temp2 = head;
	temp = new student(nm,id);
	oss<<"ID00"<<id;
	string temps = oss.str();
	temp->ID = temps;

	if(head == NULL)
	{
	head = tail = temp;
	temp->setNext(NULL);
	count++;
	}	

	else
	{
	tail->setNext(temp);
	tail=temp;
	temp->setNext(NULL);
	count++;

	}
		
		student *here = head;
		student *found = NULL;
		student *before = head;
		while(here != NULL)
			{
				if (uid == here->getID())
				{
				here->spouse = temp;
				temp->spouse = here;
				return;	
				}
			else
			before = here;
			here = here->getNext();
			}


};
コード例 #11
0
ファイル: hw04.cpp プロジェクト: breadchris/CPlusPractice
 bool operator()(student& a, student& b) {
   if (a.getName() == me) return true;
   return a.getName().compare(b.getName()) < 0 ? true : false;
 }