-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStringIntDateList.txt
More file actions
127 lines (122 loc) · 3.63 KB
/
Copy pathStringIntDateList.txt
File metadata and controls
127 lines (122 loc) · 3.63 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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
Îñíîâà
using System;
using System.Collections.Generic;
using Var7_ex_bibl;
namespace Var7_ex
{
class Program
{
static void Main(string[] args)
{
Spisok spisok = new Spisok();
bool exit = false;
while (!exit)
{
Console.WriteLine("1. Ïðîñìîòð ñïèñêà.");
Console.WriteLine("2. Äîáàâèò/Ââåñòè ñòðîêó, ÷èñëî, äàòó.");
Console.WriteLine("3. Íàéòè, óäàëèòü ýëåìåíò ñïèñêà.");
Console.WriteLine("4. Âûõîä.");
int ch = Convert.ToInt32(Console.ReadLine());
switch (ch)
{
case 1:
{
spisok.showList();
break;
}
case 2:
{
spisok.addList();
break;
}
case 3:
{
spisok.editList();
break;
}
case 4:
{
exit = true;
break;
}
}
}
}
}
}
áèáëèîòåêà
using System;
using System.Collections.Generic;
namespace Var7_ex_bibl
{
public class Spisok
{
List<object> list = new List<object>();
public void showList()
{
int k = list.Count;
if (k == 0)
{
Console.WriteLine("Ñïèñîê ïóñò.");
}
else
{
for (int i = 0; i < k; i++)
{
Console.WriteLine(list[i]);
}
}
}
public void addList()
{
Console.WriteLine("1.×èñëî 2.Ñòðîêó 3. Äàòó");
int ch = Convert.ToInt32(Console.ReadLine());
if (ch == 1)
{
Console.WriteLine("Ââåäèòå ÷èñëî: ");
int num = Convert.ToInt32(Console.ReadLine());
list.Add(num);
}
else if (ch == 2)
{
Console.WriteLine("Ââåäèòå ñòðîêó: ");
string str = Console.ReadLine();
list.Add(str);
}
else
{
Console.WriteLine("Ââåäèòå äàòó: ");
DateTime date = Convert.ToDateTime(Console.ReadLine());
list.Add(date);
}
}
public void editList()
{
Console.WriteLine("1.Ïîèñê 2.Óäàëåíèå");
int ch = Convert.ToInt32(Console.ReadLine());
if (ch == 1)
{
Console.WriteLine("Ïîèñê ïî 1.Ñîäåðæèìîìó 2.Ïî èíäåêñó ");
int num = Convert.ToInt32(Console.ReadLine());
if (num == 1)
{
Console.WriteLine("Ââåäèòå ñîäåðæèìîå: ");
string soderzhimoe = Console.ReadLine();
int k = list.Count;
int b=0;
for(int i = 0; i < k; i++)
{
if (list[i] == soderzhimoe) { b = b + i; };
}
Console.WriteLine(list[b] + "Index = " +b) ;
}
}
else if (ch == 2)
{
Console.WriteLine("Ââåäèòå èíäåêñ: ");
int index = Convert.ToInt32(Console.ReadLine());
Console.WriteLine(list[index]);
}
}
}
}