Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2017
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.18 KB | None | 0 0
  1. int i = 0;
  2. while (i < cs)
  3. {
  4.  
  5. cout << "enter item:";
  6. cin >> it;
  7.  
  8. if (find_item(it) != 1)
  9. {
  10.  
  11. list[i] = it;
  12. i++;
  13. }
  14. else
  15. cout << "item already presentn";
  16. } //while closed
  17. cl = 1;
  18.  
  19. if (list[i] == it)
  20. return 1;
  21.  
  22. {
  23. cout << "list is emptyn";
  24. }
  25. else
  26. if (cl == -1)
  27. {
  28. cout << "list is not createdn";
  29. }
  30. else
  31. for (int i = 0; i < cs; i++)
  32. {
  33. cout << list[i] << endl;
  34. }
  35.  
  36. if (find_item(it1) == 1)
  37. {
  38. int i;
  39. for (i = 0; list[i] != it1; i++)
  40. int a = list[i];
  41. list[i] = it2;
  42. cout << "at" << i << "=" << list[i] << endl;
  43. cout << "item successfully updatedn";
  44. }
  45. else
  46. cout << it1 << "is not in listn";
  47.  
  48. cout << "current size of list is:" << cs << endl;
  49.  
  50. return list[pos];
  51.  
  52. do
  53. {
  54. j++;
  55. } while (list[j] != it1);
  56.  
  57. do
  58. {
  59. k++;
  60. } while (list[k] != it2);
  61. int temp = 0;
  62. temp = list[j];
  63. list[j] = list[k];
  64. list[k] = temp;
  65.  
  66. int pd, password = 1;
  67. string un, username = "l";
  68. bool loginSuccess = false;
  69.  
  70.  
  71. do
  72. {
  73. cout << "Username : ";
  74. cin >> un;
  75. cout << "Password : ";
  76. cin >> pd;
  77.  
  78. if (username == un && password == pd)
  79. {
  80. cout << "n--------------------n";
  81. cout << "Login Successful" << endl;
  82. cout << "--------------------nn";
  83. loginSuccess = true;
  84.  
  85. }
  86. else
  87. {
  88.  
  89. cout << "n------------------------n";
  90. cout << "Invalid ID or PASSWORD !" << endl;
  91.  
  92. }
  93.  
  94. } while (!loginSuccess);
  95. printmenu();
  96.  
  97. system("pause");
  98. system("cls");
  99. int option;
  100.  
  101. cout << "****welcome to list application****n";
  102. cout << "press 0 to exitn"; //
  103. cout << "press 1 to create listn"; //
  104. cout << "press 2 to delete listn"; //
  105. cout << "press 3 to clear listn"; //
  106. cout << "press 4 to display listn"; //
  107. cout << "press 5 to add item in listn"; //
  108. cout << "press 6 to add item at particular positionn"; //
  109. cout << "press 7 to remove item from listn";
  110. cout << "press 8 to remove item from particular positionn";
  111. cout << "press 9 to swapp itemsn";//
  112. cout << "press 10 to swapp items by positionn";//
  113. cout << "press 11 to finditem in listn"; //
  114. cout << "press 12 to find item by positionn"; //
  115. cout << "press 13 to copy listn";//
  116. cout << "press 14 to update itemn"; //
  117. cout << "press 15 to update item by positionn"; //
  118. cout << "press 16 to check size of listn"; //
  119. cout << "press 17 to getelementn"; //
  120. cout << "enter 18 to check if list is fulln"; //
  121. cout << "enter 19 to check if list is emptyn"; //
  122. cout << "enter option:";
  123. cin >> option;
  124. ///////////////////////////////////////////////////
  125. switch (option)
  126. {
  127. case 0:
  128. {
  129. exit(0); //built in function to exit from program
  130. }
  131. break;
  132. //////////////////////////////////////////////////
  133.  
  134. case 1:
  135. {
  136.  
  137. m.create_list();
  138. printmenu();
  139. }
  140. break;
  141. /////////////////////////////////////////////////
  142. case 2:
  143. {
  144. m.delete_list();
  145. printmenu();
  146. }
  147. break;
  148. ////////////////////////////////////////////////
  149. case 3:
  150. {
  151. m.clear_list();
  152. printmenu();
  153. }
  154. break;
  155. ////////////////////////////////////////////////
  156. case 4:
  157. {
  158. m.display_list();
  159. printmenu();
  160. }
  161. break;
  162. ///////////////////////////////////////////////
  163. case 5:
  164. {
  165. int it;
  166. if (cl == -1)
  167. cout << "list is not createdn";
  168. else
  169. if (m.isfull() == 1)
  170. cout << "list is already fulln";
  171. else
  172. do
  173. {
  174. cout << "enter item:";
  175. cin >> it;
  176. if (m.find_item(it) == 1)
  177. cout << "item is already in listn";
  178. } while (m.find_item(it) == 1);
  179.  
  180. m.add_item(it);
  181. cout << "item added successfully in listn";
  182. cs++;
  183. }
  184. printmenu();
  185. break;
  186. //////////////////////////////////////////////
  187. case 6:
  188. {
  189. int it, pos;
  190. if (cl == -1)
  191. cout << "list is not createdn";
  192. else
  193. do
  194. {
  195. cout << "enter item:";
  196. cin >> it;
  197. if (m.find_item(it) == 1)
  198. cout << "item is already in listn";
  199. } while (m.find_item(it) == 1);
  200. cout << "enter position:";
  201. cin >> pos;
  202. if (cl == 1 && pos<cs)
  203. {
  204. for (int i = cs - 1; i>pos - 1; i--)
  205. {
  206. list[i + 1] = list[i];
  207. }
  208. m.add_item_by_position(it, pos);
  209.  
  210. cout << "item added successfully at pos :" << pos << endl;
  211. cs++;
  212. }
  213. else
  214.  
  215. if (cl == 1 && pos >= cs&&pos<ts)
  216.  
  217. {
  218. list[cs] = it;
  219. cs++;
  220. }
  221. else
  222. cout << "position out of rangen";
  223. }
  224. printmenu();
  225. break;
  226. /////////////////////////////////////////////
  227. case 7:
  228. {
  229. if (cs == 0)
  230. cout << "list is emptyn";
  231. else
  232. if (cl == -1)
  233. cout << "list is not createdn";
  234. else
  235. m.remove_item();
  236. cout << "item is successfully removedn";
  237. }
  238. printmenu();
  239. break;
  240. ////////////////////////////////////////////
  241. case 8:
  242. {
  243. if (cs == 0)
  244. cout << "list is emptyn";
  245. else
  246. if (cl == -1)
  247. cout << "list is not createdn";
  248. else
  249. m.remove_item_by_position();
  250. cout << "item successfully deletedn";
  251. }
  252. printmenu();
  253. break;
  254. ////////////////////////////////////////////
  255. case 9:
  256. {
  257. int it1, it2;
  258. if (cs == 0)
  259. cout << "list is emptyn";
  260. else
  261. if (cl == -1)
  262. cout << "list is not createdn";
  263. else
  264. do
  265. {
  266. cout << "enter item 1: ";
  267. cin >> it1;
  268. if (m.find_item(it1) != 1)
  269. cout << "item is not in listn";
  270. } while (m.find_item(it1) != 1);
  271. do
  272. {
  273. cout << "enter item 2: ";
  274. cin >> it2;
  275. if (m.find_item(it1) != 1)
  276. cout << "item is not in listn";
  277. } while (m.find_item(it2) != 1);
  278. m.swapp_items(it1, it2);
  279. cout << "items successfully swappedn";
  280.  
  281. }
  282. printmenu();
  283. break;
  284. ///////////////////////////////////////////
  285. case 10:
  286. {
  287. int pos1, pos2;
  288. if (cs == 0)
  289. cout << "list is emptyn";
  290. else
  291. if (cl == -1)
  292. cout << "list is not createdn";
  293. else
  294. do
  295. {
  296. cout << "enter position 1:";
  297. cin >> pos1;
  298. } while (pos1<0 || pos1 >= cs);
  299. do
  300. {
  301. cout << "enter position 2:";
  302. cin >> pos2;
  303. } while (pos2<0 || pos2 >= cs);
  304.  
  305. m.swapp_items_by_position(pos1, pos2);
  306. cout << "items successfully swappedn";
  307. }
  308. printmenu();
  309. break;
  310. ////////////////////////////////////////////
  311. case 11:
  312. {
  313. int it;
  314. if (cs == 0)
  315. cout << "list is emptyn";
  316. else
  317. if (cl == -1)
  318. cout << "list is not createdn";
  319. else
  320. {
  321. cout << "enter item to check its presence in listn";
  322. cin >> it;
  323. m.find_item(it);
  324. if (m.find_item(it) == 1)
  325. {
  326. cout << "item is present in list";
  327. int i = 0;
  328. while (list[i] != it)
  329. {
  330. i++;
  331. }
  332. cout << "at position " << i << endl;
  333. }
  334. else
  335. cout << "item not foundn";
  336. }
  337. printmenu();
  338. }
  339. break;
  340. //////////////////////////////////////////////
  341. case 12:
  342. {
  343. int pos;
  344. if (cs == 0)
  345. cout << "list is emptyn";
  346. else
  347. if (cl == -1)
  348. cout << "list is not createdn";
  349. else
  350. {
  351. do
  352. {
  353. cout << "enter position to find its itemn";
  354. cin >> pos;
  355. } while (pos<0 || pos>ts);
  356. m.find_item_by_pos(pos);
  357. }
  358. printmenu();
  359. }
  360. break;
  361. //////////////////////////////////////////////
  362. case 13:
  363. {
  364. if (cs == 0)
  365. cout << "list is emptyn";
  366. else
  367. if (cl == -1)
  368. cout << "list is not createdn";
  369. else
  370. m.copy_list();
  371. cout << "list copied successfullyn";
  372. }
  373. printmenu();
  374. break;
  375. /////////////////////////////////////////////
  376. case 14:
  377. {
  378. int it1, it2;
  379. if (cs == 0)
  380. cout << "list is emptyn";
  381. else
  382. if (cl == -1)
  383. cout << "list is not createdn";
  384. else
  385. {
  386. do
  387. {
  388. cout << "enter item to be updatedn";
  389. cin >> it1;
  390. if (m.find_item(it1) != 1)
  391. cout << "item is not in listn";
  392. } while (m.find_item(it1) != 1);
  393. do
  394. {
  395. cout << "enter new item to be replacedn";
  396. cin >> it2;
  397. if (m.find_item(it2) == 1)
  398. cout << "item is already in listn";
  399. } while (m.find_item(it2) == 1);
  400. m.update_item(it1, it2);
  401. }
  402. }
  403. printmenu();
  404. break;
  405. ////////////////////////////////////////////
  406. case 15:
  407. {
  408. int it, pos;
  409. if (cs == 0)
  410. cout << "list is emptyn";
  411. else
  412. if (cl == -1)
  413. cout << "list is not createdn";
  414. else
  415. {
  416. do
  417. {
  418. cout << "enter item:";
  419. cin >> it;
  420. if (m.find_item(it) == 1)
  421. cout << "item already presentn";
  422. } while (m.find_item(it) == 1);
  423. cout << "enter position:";
  424. cin >> pos;
  425. if (pos<cs)
  426. m.update_item_by_position(it, pos);
  427. else
  428. cout << "item at " << pos << " is not available to be updatedn";
  429. }
  430.  
  431.  
  432. }
  433. printmenu();
  434. break;
  435. ///////////////////////////////////////////
  436. case 16:
  437. {
  438. if (cs == 0)
  439. cout << "list is emptyn";
  440. else
  441. if (cl == -1)
  442. cout << "list is not createdn";
  443. else
  444. m.check_size_of_list();
  445.  
  446. }
  447. printmenu();
  448. break;
  449. //////////////////////////////////////////
  450. case 17:
  451. {
  452. int a, pos;
  453. if (cs == 0)
  454. cout << "list is emptyn";
  455. else
  456. if (cl == -1)
  457. cout << "list is not createdn";
  458. else
  459. do
  460. {
  461. cout << "enter position to get from list:";
  462. cin >> pos;
  463. } while (pos<0 || pos>cs);
  464. a = m.get_element_by_position(pos);
  465. cout << "here is your item from list :" << a << endl;
  466. }
  467. printmenu();
  468. break;
  469. //////////////////////////////////////////
  470. case 18:
  471. {
  472. if (cs == 0)
  473. cout << "list is emptyn";
  474. else
  475. if (cl == -1)
  476. cout << "list is not createdn";
  477. else
  478. if (m.isfull() == 1)
  479. cout << "list is fulln";
  480. else
  481. cout << "list is not fulln";
  482. }
  483. printmenu();
  484. break;
  485. /////////////////////////////////////////
  486. case 19:
  487. {
  488. if (cl == -1)
  489. cout << "list is not createdn";
  490. else
  491. if (m.isempty() == 1)
  492. cout << "list is emptyn";
  493. else
  494. cout << "list is not emptyn";
  495. }
  496. printmenu();
  497. break;
  498. /////////////////////////////////////////
  499. default:
  500. cout << "invalid optionn";
  501. printmenu();
  502. break;
  503. //////////////////////////////////////////
  504. } //switch closed
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement