Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int i = 0;
- while (i < cs)
- {
- cout << "enter item:";
- cin >> it;
- if (find_item(it) != 1)
- {
- list[i] = it;
- i++;
- }
- else
- cout << "item already presentn";
- } //while closed
- cl = 1;
- if (list[i] == it)
- return 1;
- {
- cout << "list is emptyn";
- }
- else
- if (cl == -1)
- {
- cout << "list is not createdn";
- }
- else
- for (int i = 0; i < cs; i++)
- {
- cout << list[i] << endl;
- }
- if (find_item(it1) == 1)
- {
- int i;
- for (i = 0; list[i] != it1; i++)
- int a = list[i];
- list[i] = it2;
- cout << "at" << i << "=" << list[i] << endl;
- cout << "item successfully updatedn";
- }
- else
- cout << it1 << "is not in listn";
- cout << "current size of list is:" << cs << endl;
- return list[pos];
- do
- {
- j++;
- } while (list[j] != it1);
- do
- {
- k++;
- } while (list[k] != it2);
- int temp = 0;
- temp = list[j];
- list[j] = list[k];
- list[k] = temp;
- int pd, password = 1;
- string un, username = "l";
- bool loginSuccess = false;
- do
- {
- cout << "Username : ";
- cin >> un;
- cout << "Password : ";
- cin >> pd;
- if (username == un && password == pd)
- {
- cout << "n--------------------n";
- cout << "Login Successful" << endl;
- cout << "--------------------nn";
- loginSuccess = true;
- }
- else
- {
- cout << "n------------------------n";
- cout << "Invalid ID or PASSWORD !" << endl;
- }
- } while (!loginSuccess);
- printmenu();
- system("pause");
- system("cls");
- int option;
- cout << "****welcome to list application****n";
- cout << "press 0 to exitn"; //
- cout << "press 1 to create listn"; //
- cout << "press 2 to delete listn"; //
- cout << "press 3 to clear listn"; //
- cout << "press 4 to display listn"; //
- cout << "press 5 to add item in listn"; //
- cout << "press 6 to add item at particular positionn"; //
- cout << "press 7 to remove item from listn";
- cout << "press 8 to remove item from particular positionn";
- cout << "press 9 to swapp itemsn";//
- cout << "press 10 to swapp items by positionn";//
- cout << "press 11 to finditem in listn"; //
- cout << "press 12 to find item by positionn"; //
- cout << "press 13 to copy listn";//
- cout << "press 14 to update itemn"; //
- cout << "press 15 to update item by positionn"; //
- cout << "press 16 to check size of listn"; //
- cout << "press 17 to getelementn"; //
- cout << "enter 18 to check if list is fulln"; //
- cout << "enter 19 to check if list is emptyn"; //
- cout << "enter option:";
- cin >> option;
- ///////////////////////////////////////////////////
- switch (option)
- {
- case 0:
- {
- exit(0); //built in function to exit from program
- }
- break;
- //////////////////////////////////////////////////
- case 1:
- {
- m.create_list();
- printmenu();
- }
- break;
- /////////////////////////////////////////////////
- case 2:
- {
- m.delete_list();
- printmenu();
- }
- break;
- ////////////////////////////////////////////////
- case 3:
- {
- m.clear_list();
- printmenu();
- }
- break;
- ////////////////////////////////////////////////
- case 4:
- {
- m.display_list();
- printmenu();
- }
- break;
- ///////////////////////////////////////////////
- case 5:
- {
- int it;
- if (cl == -1)
- cout << "list is not createdn";
- else
- if (m.isfull() == 1)
- cout << "list is already fulln";
- else
- do
- {
- cout << "enter item:";
- cin >> it;
- if (m.find_item(it) == 1)
- cout << "item is already in listn";
- } while (m.find_item(it) == 1);
- m.add_item(it);
- cout << "item added successfully in listn";
- cs++;
- }
- printmenu();
- break;
- //////////////////////////////////////////////
- case 6:
- {
- int it, pos;
- if (cl == -1)
- cout << "list is not createdn";
- else
- do
- {
- cout << "enter item:";
- cin >> it;
- if (m.find_item(it) == 1)
- cout << "item is already in listn";
- } while (m.find_item(it) == 1);
- cout << "enter position:";
- cin >> pos;
- if (cl == 1 && pos<cs)
- {
- for (int i = cs - 1; i>pos - 1; i--)
- {
- list[i + 1] = list[i];
- }
- m.add_item_by_position(it, pos);
- cout << "item added successfully at pos :" << pos << endl;
- cs++;
- }
- else
- if (cl == 1 && pos >= cs&&pos<ts)
- {
- list[cs] = it;
- cs++;
- }
- else
- cout << "position out of rangen";
- }
- printmenu();
- break;
- /////////////////////////////////////////////
- case 7:
- {
- if (cs == 0)
- cout << "list is emptyn";
- else
- if (cl == -1)
- cout << "list is not createdn";
- else
- m.remove_item();
- cout << "item is successfully removedn";
- }
- printmenu();
- break;
- ////////////////////////////////////////////
- case 8:
- {
- if (cs == 0)
- cout << "list is emptyn";
- else
- if (cl == -1)
- cout << "list is not createdn";
- else
- m.remove_item_by_position();
- cout << "item successfully deletedn";
- }
- printmenu();
- break;
- ////////////////////////////////////////////
- case 9:
- {
- int it1, it2;
- if (cs == 0)
- cout << "list is emptyn";
- else
- if (cl == -1)
- cout << "list is not createdn";
- else
- do
- {
- cout << "enter item 1: ";
- cin >> it1;
- if (m.find_item(it1) != 1)
- cout << "item is not in listn";
- } while (m.find_item(it1) != 1);
- do
- {
- cout << "enter item 2: ";
- cin >> it2;
- if (m.find_item(it1) != 1)
- cout << "item is not in listn";
- } while (m.find_item(it2) != 1);
- m.swapp_items(it1, it2);
- cout << "items successfully swappedn";
- }
- printmenu();
- break;
- ///////////////////////////////////////////
- case 10:
- {
- int pos1, pos2;
- if (cs == 0)
- cout << "list is emptyn";
- else
- if (cl == -1)
- cout << "list is not createdn";
- else
- do
- {
- cout << "enter position 1:";
- cin >> pos1;
- } while (pos1<0 || pos1 >= cs);
- do
- {
- cout << "enter position 2:";
- cin >> pos2;
- } while (pos2<0 || pos2 >= cs);
- m.swapp_items_by_position(pos1, pos2);
- cout << "items successfully swappedn";
- }
- printmenu();
- break;
- ////////////////////////////////////////////
- case 11:
- {
- int it;
- if (cs == 0)
- cout << "list is emptyn";
- else
- if (cl == -1)
- cout << "list is not createdn";
- else
- {
- cout << "enter item to check its presence in listn";
- cin >> it;
- m.find_item(it);
- if (m.find_item(it) == 1)
- {
- cout << "item is present in list";
- int i = 0;
- while (list[i] != it)
- {
- i++;
- }
- cout << "at position " << i << endl;
- }
- else
- cout << "item not foundn";
- }
- printmenu();
- }
- break;
- //////////////////////////////////////////////
- case 12:
- {
- int pos;
- if (cs == 0)
- cout << "list is emptyn";
- else
- if (cl == -1)
- cout << "list is not createdn";
- else
- {
- do
- {
- cout << "enter position to find its itemn";
- cin >> pos;
- } while (pos<0 || pos>ts);
- m.find_item_by_pos(pos);
- }
- printmenu();
- }
- break;
- //////////////////////////////////////////////
- case 13:
- {
- if (cs == 0)
- cout << "list is emptyn";
- else
- if (cl == -1)
- cout << "list is not createdn";
- else
- m.copy_list();
- cout << "list copied successfullyn";
- }
- printmenu();
- break;
- /////////////////////////////////////////////
- case 14:
- {
- int it1, it2;
- if (cs == 0)
- cout << "list is emptyn";
- else
- if (cl == -1)
- cout << "list is not createdn";
- else
- {
- do
- {
- cout << "enter item to be updatedn";
- cin >> it1;
- if (m.find_item(it1) != 1)
- cout << "item is not in listn";
- } while (m.find_item(it1) != 1);
- do
- {
- cout << "enter new item to be replacedn";
- cin >> it2;
- if (m.find_item(it2) == 1)
- cout << "item is already in listn";
- } while (m.find_item(it2) == 1);
- m.update_item(it1, it2);
- }
- }
- printmenu();
- break;
- ////////////////////////////////////////////
- case 15:
- {
- int it, pos;
- if (cs == 0)
- cout << "list is emptyn";
- else
- if (cl == -1)
- cout << "list is not createdn";
- else
- {
- do
- {
- cout << "enter item:";
- cin >> it;
- if (m.find_item(it) == 1)
- cout << "item already presentn";
- } while (m.find_item(it) == 1);
- cout << "enter position:";
- cin >> pos;
- if (pos<cs)
- m.update_item_by_position(it, pos);
- else
- cout << "item at " << pos << " is not available to be updatedn";
- }
- }
- printmenu();
- break;
- ///////////////////////////////////////////
- case 16:
- {
- if (cs == 0)
- cout << "list is emptyn";
- else
- if (cl == -1)
- cout << "list is not createdn";
- else
- m.check_size_of_list();
- }
- printmenu();
- break;
- //////////////////////////////////////////
- case 17:
- {
- int a, pos;
- if (cs == 0)
- cout << "list is emptyn";
- else
- if (cl == -1)
- cout << "list is not createdn";
- else
- do
- {
- cout << "enter position to get from list:";
- cin >> pos;
- } while (pos<0 || pos>cs);
- a = m.get_element_by_position(pos);
- cout << "here is your item from list :" << a << endl;
- }
- printmenu();
- break;
- //////////////////////////////////////////
- case 18:
- {
- if (cs == 0)
- cout << "list is emptyn";
- else
- if (cl == -1)
- cout << "list is not createdn";
- else
- if (m.isfull() == 1)
- cout << "list is fulln";
- else
- cout << "list is not fulln";
- }
- printmenu();
- break;
- /////////////////////////////////////////
- case 19:
- {
- if (cl == -1)
- cout << "list is not createdn";
- else
- if (m.isempty() == 1)
- cout << "list is emptyn";
- else
- cout << "list is not emptyn";
- }
- printmenu();
- break;
- /////////////////////////////////////////
- default:
- cout << "invalid optionn";
- printmenu();
- break;
- //////////////////////////////////////////
- } //switch closed
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement