-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathKod17_Stacks.cs
More file actions
32 lines (27 loc) · 1.15 KB
/
Kod17_Stacks.cs
File metadata and controls
32 lines (27 loc) · 1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
using System.Diagnostics;
using System.Reflection.Metadata.Ecma335;
using System.Reflection.PortableExecutable;
using System.Linq;
using System.Collections.Generic;
using System.Diagnostics.Metrics;
/*Задача 17: Stack<T> — стек для undo
Задача
Создай стек строк (история действий).
Добавь в стек действия: "Открыл файл", "Написал текст", "Удалил слово", "Сохранил".
Затем сделай 2 undo (Pop) и выведи, какое действие отменено и что осталось в стеке.*/
class Program
{
static void Main()
{
Stack<string> undo = new Stack<string>();
undo.Push("Открыл файл");
undo.Push("Написал текст");
undo.Push("Удалил");
undo.Push("Сохранил");
string first = undo.Pop();
Console.WriteLine($"Отменено: {first}");
string second = undo.Pop();
Console.WriteLine($"Отменено: {second}");
Console.WriteLine("Оставшиеся действия: " + string.Join(", ", undo));
}
}