Advertisement
Motekoni

THREE

Apr 7th, 2016
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 25.90 KB | None | 0 0
  1. //////// עץ בינארי ///////////
  2. // החזרת סכום ערכים ברמה בעץ
  3. static int printFloorSum(BinTreeNode<int> t, int floor,int sum = 0)
  4. {
  5. if (t != null)
  6. {
  7. if (floor == 0)
  8. {
  9. sum = sum + t.GetInfo();
  10. return sum;
  11. }
  12.  
  13. return (printFloorSum(t.GetLeft(), floor - 1, sum) + printFloorSum(t.GetRight(), floor - 1, sum));
  14.  
  15. }
  16. return 0;
  17.  
  18.  
  19. }
  20. // מיון עץ
  21.  
  22. // מציאת ערך מקסימלי
  23. static int getTreeMax(BinTreeNode<int> t, int max = 0)
  24. {
  25. if (t != null)
  26. {
  27. if (t.GetInfo() > max)
  28. {
  29. max = t.GetInfo();
  30. }
  31. return (Math.Max((getTreeMax(t.GetLeft(),max)),getTreeMax(t.GetRight(),max)));
  32. }
  33. return max;
  34. }
  35. // מציאת ערך מינימאלי
  36. static int getTreeMin(BinTreeNode<int> t, int min)
  37. {
  38. if (t != null)
  39. {
  40. if (t.GetInfo() < min)
  41. {
  42. min = t.GetInfo();
  43. }
  44. return (Math.Min((getTreeMin(t.GetLeft(), min)), getTreeMin(t.GetRight(), min)));
  45.  
  46. }
  47. return min;
  48.  
  49. }
  50. // מחיקת צומת בידיעה שכל בניה הבאים יימחקו גם כן
  51. static void deleteValueTree(BinTreeNode<int> t, BinTreeNode<int> s)
  52. {
  53. if (t != null)
  54. {
  55. if (t.GetLeft() == s)
  56. {
  57. t.SetLeft(null);
  58. }
  59. else if (t.GetRight() == s)
  60. {
  61. t.SetRight(null);
  62. }
  63. deleteValueTree(t.GetLeft(),s);
  64. deleteValueTree(t.GetRight(),s);
  65.  
  66. }
  67.  
  68.  
  69. }
  70. // איפוס ערך בעץ
  71. static void zeroForValueTree(BinTreeNode<int> t, BinTreeNode<int> s)
  72. {
  73. if (t != null)
  74. {
  75. if (t == s)
  76. {
  77. t.SetInfo(0);
  78. }
  79. zeroForValueTree(t.GetLeft(), s);
  80. zeroForValueTree(t.GetRight(), s);
  81. }
  82.  
  83. }
  84. // מיון עץ בינארי
  85. static Queue<int> sortTree(BinTreeNode<int> t,Queue<int> q)
  86. {
  87. Queue<int> q1 = new Queue<int>();
  88. return q1;
  89. }
  90. // הדפת ערכים ברמה מסויימת של העץ
  91. static void printValueOfFloor(BinTreeNode<int> t, int f)
  92. {
  93. if (t != null)
  94. {
  95. if (f == 0)
  96. {
  97. Console.WriteLine(t.GetInfo());
  98. }
  99. else
  100. {
  101. printValueOfFloor(t.GetRight(), f - 1);
  102. printValueOfFloor(t.GetLeft(), f - 1);
  103. }
  104. }
  105.  
  106. }
  107. // החזרת מספר צמתים ברמה מסויימת
  108. static int getFloorNumValues(BinTreeNode<int> t, int f)
  109. {
  110. if (t != null)
  111. {
  112. if (f == 0)
  113. {
  114. return 1;
  115. }
  116. return (getFloorNumValues(t.GetLeft(), f - 1) + getFloorNumValues(t.GetRight(), f - 1));
  117. }
  118. return 0;
  119. }
  120. // קבלת ערך והדפסת הרמה הראשונה בה הוא מופיע
  121. static void printFloorByValue(BinTreeNode<int> t, int f, int level = 0)
  122. {
  123. if (t != null)
  124. {
  125. if (t.GetInfo() == f)
  126. {
  127. Console.WriteLine(level);
  128. }
  129. printFloorByValue(t.GetLeft(), f, level + 1);
  130. printFloorByValue(t.GetRight(), f, level + 1);
  131.  
  132.  
  133. }
  134.  
  135. }
  136. // הדפסה
  137. static void prePrint(BinTreeNode<int> t)
  138. {
  139. if (t != null)
  140. {
  141.  
  142. Console.WriteLine(t.GetInfo());
  143. prePrint(t.GetLeft());
  144. prePrint(t.GetRight());
  145. }
  146.  
  147. }
  148. // הדפסת בנים שמאליים בלבד
  149. public static void benSmol(BinTreeNode<int> t, bool smol = false)
  150. {
  151. if (t != null)
  152. {
  153. if (smol)
  154. {
  155. Console.Write(t.GetInfo() + " ");
  156.  
  157. }
  158. benSmol(t.GetLeft(), true);
  159. benSmol(t.GetRight(), false);
  160.  
  161. }
  162. }
  163. // בדיקת גובה העץ
  164. public static int height(BinTreeNode<int> t)
  165. {
  166. if (t != null)
  167. {
  168. if (!hasSons(t))
  169. {
  170. return 1;
  171. }
  172. return (Math.Max((height(t.GetLeft()) + 1), (height(t.GetRight()) + 1)));
  173. }
  174. return 0;
  175.  
  176. }
  177. static bool hasRight(BinTreeNode<int> t)
  178. {
  179. return t.GetRight() != null;
  180. }
  181. static bool hasLeft(BinTreeNode<int> t)
  182. {
  183. return t.GetLeft() != null;
  184. }
  185. static bool hasSons(BinTreeNode<int> t)
  186. {
  187. return hasRight(t) || hasLeft(t);
  188. }
  189. // האם ערך קיים בעץ
  190. static bool valueExists(BinTreeNode<int> t, int m)
  191. {
  192. if (t != null)
  193. {
  194. if (t.GetInfo() == m)
  195. {
  196. return true;
  197. }
  198. return ((valueExists(t.GetLeft(), m)) || valueExists(t.GetRight(), m));
  199. }
  200. else
  201. {
  202. return false;
  203. }
  204. }
  205. // הדפסה תוכית
  206. static void inPrint(BinTreeNode<int> t)
  207. {
  208. if (t != null)
  209. {
  210. inPrint(t.GetLeft());
  211. Console.Write(t.GetInfo() + " ");
  212. inPrint(t.GetRight());
  213. }
  214.  
  215. }
  216. // הדפסה סופית
  217. static void sofPrint(BinTreeNode<int> t)
  218. {
  219. if (t != null)
  220. {
  221. sofPrint(t.GetLeft());
  222. sofPrint(t.GetRight());
  223. Console.WriteLine(t.GetInfo());
  224. }
  225. }
  226. //////////// מחסנית //////////////
  227. // פעולה של הפיכת מחסנית
  228. public static void DebugStack(Stack<int> s, int n)
  229. {
  230. Stack<int> tmp = CloneStack(s);// FlipStack(s); //!פעולה של הפיכת מחסנית, מופיע בדף
  231. while (!s.IsEmpty())
  232. s.Pop();
  233. while (!tmp.IsEmpty())
  234. {
  235. int x = tmp.Pop();
  236. if (x != n)
  237. s.Push(x);
  238. }
  239. }
  240. // מיון
  241. public static Stack<int> sortnoarrays(Stack<int> UnSortedStack)
  242. {
  243. int x = howmuch(UnSortedStack);
  244. Stack<int> temp = CloneStack(UnSortedStack);
  245. Stack<int> temp1 = new Stack<int>();
  246. while(x!=0)
  247. {
  248. int maximum = findmax(temp);
  249. temp1.Push(maximum);
  250. DebugStack(UnSortedStack, maximum);
  251. temp = UnSortedStack;
  252. x--;
  253. }
  254. UnSortedStack = temp1;
  255. return temp1;
  256. }
  257. // מציאת ערך מקסימלי
  258. public static int findmax(Stack<int> UnSortedStack)
  259. {
  260. int max = 0;
  261. Stack<int> temp = CloneStack(UnSortedStack);
  262. while (!temp.IsEmpty())
  263. {
  264. int y=temp.Pop();
  265. if (y > max)
  266. {
  267. max = y;
  268. }
  269. }
  270. return max;
  271. }
  272. // כמה איברים במחסנית
  273. public static int howmuch(Stack<int> random)//we check how much numbers/chars are in the stack
  274. {
  275. int count = 0;
  276. Stack<int> temp = CloneStack(random);
  277. while (!temp.IsEmpty())
  278. {
  279. temp.Pop();
  280. count++;
  281.  
  282. }
  283. return count;
  284. }
  285. // העתקת מחסנית
  286. public static Stack<int> CloneStack(Stack<int> s)
  287. {
  288. Stack<int> newS = new Stack<int>();
  289. Stack<int> tmp = new Stack<int>();
  290. while (!s.IsEmpty())
  291. tmp.Push(s.Pop());
  292. while (!tmp.IsEmpty())
  293. {
  294. newS.Push(tmp.Top());
  295. s.Push(tmp.Pop());
  296. }
  297. return newS;
  298. }
  299. // מחיקת ערך ממחסנית
  300. static Stack<int> delete(Stack<int> p, int num)
  301. {
  302. Stack<int> a = p;
  303. Stack<int> newStack = new Stack<int>();
  304. int i = 0;
  305. int b = a.Pop();
  306. while (a.IsEmpty() == false)
  307. {
  308. if (b != num)
  309. {
  310. newStack.Push(b);
  311. }
  312. else
  313. {
  314. /* i++;
  315. if (i > 0)
  316. {
  317. newStack.Push(num);
  318. } */
  319. }
  320. b = a.Pop();
  321.  
  322. }
  323. return newStack;
  324. }
  325. // מיון מחסנית
  326. static Stack<int> sort(Stack<int> m)
  327. {
  328. Stack<int> m1 = new Stack<int>();
  329. Stack<int> newM = new Stack<int>();
  330. int max = 0;
  331.  
  332. while (m.IsEmpty() == false || m1.IsEmpty() == false)
  333. {
  334. Console.WriteLine("NEW: " + newM);
  335. while (m.IsEmpty() == false)
  336. {
  337.  
  338. m1.Push(m.Pop());
  339. if (m1.Top() > max)
  340. {
  341. max = m1.Top();
  342. }
  343. Console.WriteLine("MAX: " + max);
  344. Console.WriteLine(m);
  345. Console.WriteLine(m1);
  346. }
  347. m1 = delete(m1, max);
  348. Console.WriteLine("AFTER DELETE:" + m1);
  349. newM.Push(max);
  350. Console.WriteLine("NEW: " + newM);
  351.  
  352. while (m1.IsEmpty() == false)
  353. {
  354.  
  355. m.Push(m1.Pop());
  356. }
  357. Console.WriteLine(m);
  358. max = 0;
  359. }
  360. return newM;
  361.  
  362. }
  363. // בדיקה האם ערך נמצא ברצף בתור
  364. public static bool bdika(Queue<int> q, int m)
  365. {
  366. Queue<int> p = new Queue<int>();
  367. int i = 0;
  368. p = cloneQueue(q);
  369. int a = q.Remove();
  370. while (p.IsEmpty() == false)
  371. {
  372. int b = p.Head();
  373. if (a == b && a == m)
  374. {
  375. return true;
  376. }
  377.  
  378. a = p.Remove();
  379.  
  380.  
  381. }
  382. return false;
  383.  
  384. }
  385. // בדיקה האם ערך נמצא בתור
  386. public static bool exist(Queue<int> q, int m)
  387. {
  388. Queue<int> b = new Queue<int>();
  389. b = cloneQueue(q);
  390. while (!b.IsEmpty())
  391. {
  392. if (b.Remove() == m)
  393. {
  394. return true;
  395. }
  396.  
  397. }
  398. return false;
  399. }
  400. // מציאת מספר ערכים בין X לY בתור
  401. public static int getNumbersBetween(Queue<int> q, int low, int high)
  402. {
  403. int count = 0;
  404. Queue<int> m = cloneQueue(q);
  405. while (m.IsEmpty() == false)
  406. {
  407. int num = m.Remove();
  408. if (num >= low && num <= high)
  409. {
  410. count++;
  411. }
  412. }
  413. return count;
  414. }
  415. // האם תור ממויין
  416. public static bool isSorted(Queue<int> q)
  417. {
  418. Queue<int> q1 = cloneQueue(q);
  419. int num = q1.Remove();
  420. if (num > q1.Head() || num == q1.Head())
  421. {
  422. // מהגדול לקטן
  423. while (q1.IsEmpty() == false)
  424. {
  425.  
  426. if (num < q1.Head())
  427. {
  428. return false;
  429. }
  430. num = q1.Remove();
  431. Console.WriteLine(num);
  432. }
  433. }
  434. else
  435. {
  436. // מהקטן לגדול
  437. while (q1.IsEmpty() == false)
  438. {
  439. if (num > q1.Head())
  440. {
  441. return false;
  442. }
  443. num = q1.Remove();
  444. Console.WriteLine(num);
  445. }
  446. }
  447. return true;
  448.  
  449.  
  450. }
  451. // מציאת הערך המקסימלי בתור
  452. public static int getMax(Queue<int> q)
  453. {
  454. Queue<int> m = cloneQueue(q);
  455. int max = 0;
  456. while (m.IsEmpty() == false)
  457. {
  458. if (m.Head() > max)
  459. {
  460. max = m.Head();
  461. }
  462. m.Remove();
  463.  
  464. }
  465. return max;
  466. }
  467. // מציאת הערך המינימלי ביותר בתור
  468. public static int getMin(Queue<int> m)
  469. {
  470. Queue<int> p = new Queue<int>();
  471. p = cloneQueue(m);
  472. int min = p.Head();
  473. while (p.IsEmpty() == false)
  474. {
  475. if (min > p.Head())
  476. {
  477. min = p.Head();
  478. }
  479. p.Remove();
  480. }
  481.  
  482. return min;
  483. }
  484. //מחיקת כל הערכים השווים לערך מסויים מהתור
  485. public static Queue<int> delete(Queue<int> m, int s)
  486. {
  487. Queue<int> p = new Queue<int>();
  488. while (m.IsEmpty() == false)
  489. {
  490. if (m.Head() != s)
  491. {
  492. p.Insert(m.Head());
  493.  
  494. }
  495. m.Remove();
  496. }
  497. return p;
  498. }
  499. //החזרת תור ללא כפילויות מספרים
  500. public static Queue<int> kfilut(Queue<int> q)
  501. {
  502. Queue<int> m = new Queue<int>();
  503. while (q.IsEmpty() == false)
  504. {
  505. int num = q.Remove();
  506. if (exist(q, num) == false)
  507. {
  508. m.Insert(num);
  509. }
  510. }
  511. return m;
  512. }
  513. //מיון תור עלייה
  514. public static Stack<int> ole(Queue<int> q)
  515. {
  516. Queue<int> p = new Queue<int>();
  517. Stack<int> s = new Stack<int>();
  518. p = cloneQueue(q);
  519. while (p.IsEmpty() == false)
  520. {
  521. int m = getMin(p);
  522. s.Push(m);
  523. p = delete(p, m);
  524. }
  525. return s;
  526.  
  527. }
  528. // מיזוג תורים לתור אחד ממויין בסדר עולה
  529. public static Queue<int> bobo(Queue<int> q, Queue<int> q1)
  530. {
  531. Queue<int> s = new Queue<int>();
  532. int num;
  533. while (q1.IsEmpty() == false && q.IsEmpty() == false)
  534. {
  535. if (q.Head() > q1.Head())
  536. {
  537. num = q.Remove();
  538. }
  539. else
  540. {
  541. num = q1.Remove();
  542. }
  543. Console.WriteLine(num);
  544. s.Insert(num);
  545. }
  546. if (q1.IsEmpty())
  547. {
  548. while (q.IsEmpty() == false)
  549. {
  550. s.Insert(q.Remove());
  551. }
  552. }
  553. else
  554. {
  555. while (q1.IsEmpty() == false)
  556. {
  557. s.Insert(q1.Remove());
  558. }
  559. }
  560. return s;
  561. }
  562. // מיזוג תורים קלאסי
  563. public static Queue<int> Mizug(Queue<int> q, Queue<int> q1)
  564. {
  565. while (q1.IsEmpty() == false)
  566. {
  567. q.Insert(q.Remove());
  568. q.Insert(q1.Remove());
  569. }
  570. return q;
  571.  
  572. }
  573. // אורך התור
  574. public static int LengthQueue(Queue<int> q)
  575. {
  576. int length = 0;
  577. Queue<int> qCopy = cloneQueue(q); //!
  578. while (!qCopy.IsEmpty())
  579. {
  580. length++;
  581. qCopy.Remove();
  582. }
  583. return length;
  584. }
  585. // קבלת ערך מסויים במקום מסויים בתור
  586. static int getValueInSpecificPlace(Queue<int> m, int place)
  587. {
  588.  
  589. int i = 0;
  590. Queue<int> s = cloneQueue(m);
  591. while (s.IsEmpty() == false)
  592. {
  593. i++;
  594. if (i == place)
  595. {
  596. return s.Head();
  597. }
  598. s.Remove();
  599. }
  600. return -999;
  601. }
  602. // קבלת מספר ערכים בתור
  603. static int getCount(Queue<int> m)
  604. {
  605. Queue<int> s = cloneQueue(m);
  606. int num = 0;
  607. while (s.IsEmpty() == false)
  608. {
  609. num++;
  610. s.Remove();
  611. }
  612.  
  613. return num;
  614. }
  615. // סכום תור
  616. static int queueSum(Queue<int> m)
  617. {
  618. Queue<int> clone = cloneQueue(m);
  619. int sum = 0;
  620. while (clone.IsEmpty() == false)
  621. {
  622. sum = sum + clone.Remove();
  623.  
  624. }
  625. return sum;
  626.  
  627. }
  628. // העתקת תור
  629. static Queue<int> cloneQueue(Queue<int> q)
  630. {
  631. Queue<int> temp1 = new Queue<int>();
  632. Queue<int> temp2 = new Queue<int>();
  633. while (!q.IsEmpty())
  634. {
  635. temp1.Insert(q.Head());
  636. temp2.Insert(q.Remove());
  637. }
  638. while (!temp2.IsEmpty()) // החזרת התור למצבו המקורי
  639. {
  640. q.Insert(temp2.Remove());
  641. }
  642. return temp1;
  643. }
  644. /////////////// שרשרת חוליות /////////////
  645.  
  646. public static Node<int> cloneNode(Node<int> temp)
  647. {
  648. Node<int> neww = new Node<int>(temp.GetInfo());
  649. Node<int> neww2 = new Node<int>(temp.GetInfo());
  650. neww2 = neww2.GetNext();
  651. while (neww2.GetNext() != null)
  652. {
  653. neww.SetNext(neww2);
  654. neww2 = neww2.GetNext();
  655. }
  656. return neww;
  657.  
  658. }
  659. // טענת כניסה: הפעולה מקבלת רשימה של מספרים שלמים
  660. // טענת כניסה: הפעולה מחזירה את סכום כל איברי הרשימה
  661. // סיבוכיות זמן ריצה: O(n)
  662. public static int SumList(Node<int> l)
  663. {
  664. int sum = 0;
  665. Node<int> pos = l;
  666. while (pos != null)
  667. {
  668. sum += pos.GetInfo();
  669. pos = pos.GetNext();
  670. }
  671. return sum;
  672. }
  673. // טענת כניסה: הפעולה מקבלת רשימה של מספרים שלמים
  674. // טענת יציאה: הפעולה מחזירה את אורך הרשימה - מספר החוליות בה
  675. // סיבוכיות זמן ריצה: O(n)
  676. public static int LengthList(Node<int> l)
  677. {
  678. int length = 0;
  679. Node<int> pos = l;
  680. while (pos != null)
  681. {
  682. length++;
  683. pos = pos.GetNext();
  684. }
  685. return length;
  686. }
  687. // טענת כניסה: הפעולה מקבלת רשימה של מספרים שלמים ומספר שלם
  688. // טענת יציאה: הפעולה מחזירה את מספר הפעמים שהמספר מופיע ברשימה
  689. // סיבוכיות זמן ריצה: O(n)
  690. public static int HowManyList(Node<int> l, int n)
  691. {
  692. int count = 0;
  693. Node<int> pos = l;
  694. while (pos != null)
  695. {
  696. if (pos.GetInfo() == n)
  697. count++;
  698. pos = pos.GetNext();
  699. }
  700. return count;
  701. }
  702.  
  703. // טענת כניסה: הפעולה מקבלת רשימה של מספרים שלמים
  704. // טענת יציאה: הפעולה מחזירה "אמת" אם הרשימה ממוינת בסדר עולה, אחרת מחזירה "שקר"
  705. // סיבוכיות זמן ריצה: O(n)
  706. public static bool IsSorted(Node<int> l)
  707. {
  708. Node<int> pos = l;
  709. while (pos.GetNext() != null)
  710. {
  711. if (pos.GetInfo() > pos.GetNext().GetInfo())
  712. return false;
  713. pos = pos.GetNext();
  714. }
  715. return true;
  716. }
  717. // מחיקת חוליה מהשרשרת
  718. public static Node<int> delete(Node<int> p, Node<int> n)
  719. {
  720. Node<int> s = p;
  721. while (p != null)
  722. {
  723. if (p.GetNext() == n)
  724. {
  725. p.SetNext(n.GetNext());
  726. }
  727. p = p.GetNext();
  728. }
  729.  
  730. return s;
  731. }
  732. // ניגודים בשרשרת חוליות
  733. public static Node<int> nigud(Node<int> n)
  734. {
  735. Node<int> p = n;
  736. bool fuck = false;
  737. while (n != null)
  738. {
  739. if (n.GetInfo() != 0)
  740. {
  741. int m = n.GetInfo() * -1;
  742. n.SetNext(new Node<int>(m, n.GetNext()));
  743. fuck = true;
  744. }
  745. else
  746. {
  747. if (p == n)
  748. {
  749. p = n.GetNext();
  750. }
  751. else
  752. {
  753. delete(p, n);
  754. }
  755. }
  756. if (!fuck)
  757. {
  758. n = n.GetNext();
  759.  
  760. }
  761. else
  762. {
  763. n = n.GetNext().GetNext();
  764. }
  765. fuck = false;
  766. }
  767. return p;
  768. }
  769.  
  770. ////////// מחסנית ////////////
  771. // היפוך מחסנית
  772. public static Stack<int> FlipStack(Stack<int> s)
  773. {
  774. Stack<int> newS = new Stack<int>();
  775. Stack<int> tmp = CloneStack(s); //!
  776. while (!tmp.IsEmpty())
  777. newS.Push(tmp.Pop());
  778. return newS;
  779. }
  780.  
  781.  
  782.  
  783. // עדכון המחסנית לרצף המספרים הארוך ביותר
  784. static void getOnlyRezef(Stack<int> stk)
  785. {
  786. int i = 1;
  787. int max = 1;
  788. int j = 0, place = 1;
  789. Stack<int> p = CloneStack(stk);
  790. Stack<int> copy = CloneStack(stk);
  791. Stack<int> s = new Stack<int>();
  792. int num = p.Pop();
  793. bool fuck = false;
  794. // רק עלייה
  795. // כדי לבצע ירידה צריך לבדוק את ההפרש הראשוני בכל רצף ולהשוות את ההפרשים הבאים אליו
  796. while (p.IsEmpty() == false)
  797. {
  798. place++;
  799. if (p.Top() - num == -1)
  800. {
  801.  
  802. i++;
  803. Console.WriteLine("MY I:" + i);
  804. Console.WriteLine(p.Top());
  805. }
  806. else
  807. {
  808.  
  809. if (i > max)
  810. {
  811. max = i;
  812. j = place - max;
  813.  
  814. }
  815. i = 1;
  816.  
  817. }
  818.  
  819. num = p.Pop();
  820. if (p.IsEmpty() == true)
  821. {
  822.  
  823. if (i > max)
  824. {
  825. max = i;
  826. j = place - max + 1;
  827. }
  828. }
  829. }
  830. Console.WriteLine("i:" + max);
  831. Console.WriteLine("j:" + j);
  832. if (j != 0)
  833. {
  834. // J => מיקום התחלת הרצף
  835. // MAX => מספר איברי הרצף
  836. int pogi = 0;
  837. bool done = false;
  838. while (copy.IsEmpty() == false)
  839. {
  840. pogi++;
  841. if (pogi == j)
  842. {
  843.  
  844. while (max != 0)
  845. {
  846.  
  847. s.Push(copy.Top());
  848. Console.WriteLine(copy.Pop());
  849. max--;
  850.  
  851.  
  852. }
  853. done = true;
  854.  
  855. }
  856. if (!done)
  857. {
  858. copy.Pop();
  859. }
  860. }
  861. Console.WriteLine(s);
  862. }
  863. else
  864. {
  865. Console.WriteLine("NO REZEF");
  866. }
  867.  
  868. }
  869. // ניקוי מחסנית
  870. static Stack<int> clean(Stack<int> s)
  871. {
  872. while (s.IsEmpty() == false)
  873. {
  874. s.Pop();
  875. }
  876. return s;
  877.  
  878. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement