Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- static void sprawdzenie(int[]ciagwyjsciowy)
- {
- int[] ciagwejsciowy = new int[ciagwyjsciowy.Length];
- for (int i = 0; i < ciagwejsciowy.Length; i++)
- {
- ciagwejsciowy[i] = i;
- }
- Stack<int> s1 = new Stack<int>();
- Queue<int> q1 = new Queue<int>();
- int[] wyjscie = new int[ciagwejsciowy.Length];
- int tmp = 0;
- int j = 0;
- for (int i = 0; i < ciagwejsciowy.Length; i++)
- {
- tmp = ciagwejsciowy[i];
- s1.Push(tmp);
- while (s1.Count > 0 && tmp >= ciagwyjsciowy[j])
- {
- q1.Enqueue(s1.Pop());
- j++;
- }
- }
- foreach (var item in q1)
- {
- Console.Write(item + " ");
- }
- for (int i = 0; i < wyjscie.Length; i++)
- {
- wyjscie[i] = q1.Dequeue();
- }
- bool mozliwe = true;
- for (int i = 0; i < ciagwejsciowy.Length; i++)
- {
- if (ciagwyjsciowy[i]!=wyjscie[i])
- {
- mozliwe = false;
- Console.WriteLine($"czy jest mozliwe? {mozliwe}");
- return;
- }
- }
- //mozliwe = true;
- Console.WriteLine($"czy jest mozliwe? {mozliwe}");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement