Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include "DLL.h"
- using namespace std;
- void CreateList(List &L){
- first(L) = NULL;
- last(L) = NULL;
- }
- void InsertFirst(List &L,address P){
- if(first(L) == NULL){
- first(L) = P;
- last(L) = P;
- return;
- }
- next(P) = first(L);
- prev(first(L)) = P;
- first(L) = P;
- }
- void DeleteFirst(List &L, address &P){
- P = first(L);
- first(L) = next(P);
- if(first(L) != NULL){
- prev(first(L)) = NULL;
- }
- if(last(L) == P){
- last(L) = NULL;
- }
- next(P) = NULL;
- prev(P) = NULL;
- }
- address createNewElement(string name,float rating){
- address P = new elmList;
- next(P) = NULL;
- prev(P) = NULL;
- info(P).name = name;
- info(P).rating = rating;
- return P;
- }
- void ShowList(List &L){
- address P = first(L);
- while(P != NULL){
- cout<<"=================="<<endl;
- cout<<"Data Driver" <<endl;
- cout<<"Nama : " << info(P).name << endl;
- cout<<"Rating : " << info(P).rating << endl;
- cout<<"=================="<<endl;
- P = next(P);
- }
- }
- void Reset(List &L){
- float totalDriver;
- float CurrentRate;
- while(first(L) != NULL){
- address P;
- DeleteFirst(L,P);
- cout<<"=================="<<endl;
- cout<<"Delete Data Driver" <<endl;
- cout<<"Nama : " << info(P).name << endl;
- cout<<"Rating : " << info(P).rating << endl;
- cout<<"=================="<<endl;
- totalDriver++;
- CurrentRate += info(P).rating;
- }
- CurrentRate = CurrentRate/totalDriver;
- cout<<"Data List telah di reset"<<endl;
- cout<<"Average rating : " << CurrentRate << endl;
- }
- void SplitData(float N,List &L,List &under,List &upper){
- while(first(L) != NULL){
- address P;
- DeleteFirst(L,P);
- if(info(P).rating >= N){
- InsertFirst(upper,P);
- }else{
- InsertFirst(under,P);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement