-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
97 lines (86 loc) · 2.83 KB
/
Program.cs
File metadata and controls
97 lines (86 loc) · 2.83 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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
namespace ConsoleApp16
{
public class Program
{
public static string[] readingFile()
{
string path = @"C:\Users\User\Desktop\test.csv";
string[] lines = File.ReadAllLines(path);
return lines;
}
public static int countAll(string[] lines)
{
int count = 0;
count = lines.Length - 1;
return count;
}
public static int countOfDormitory(string[] lines)
{
int count = 0;
for (int i = 1; i < lines.Length; i++)
{
for (int j = 0; j < 6; j++)
{
lines[i] = lines[i].Substring(0, lines[i].LastIndexOf(';'));
}
if (lines[i][lines[i].Length-1] == 'а')
{
count++;
}
}
return count;
}
public static int[] countOfCourses(string[] lines)
{
int[] course = new int[3];
for (int i = 1; i < lines.Length; i++)
{
for (int j = 0; j < 2; j++)
{
lines[i] = lines[i].Substring(lines[i].IndexOf(';') + 1);
}
switch (lines[i][0])
{
case '1':
course[0]++;
break;
case '2':
course[1]++;
break;
case '3':
course[2]++;
break;
default:
break;
}
}
return course;
}
static void Main(string[] args)
{
string[] linesFile = readingFile();
int[] courses = countOfCourses(linesFile);
Console.Write("Всего анкет: ");
Console.WriteLine(countAll(linesFile));
Console.Write("Анкет первого курса: ");
Console.WriteLine(courses[0]);
Console.Write("Анкет второго курса: ");
Console.WriteLine(courses[1]);
Console.Write("Анкет третьего курса: ");
Console.WriteLine(courses[2]);
Console.Write("Людей, проживающих в общажитии: ");
Console.WriteLine(countOfDormitory(linesFile));
}
}
}
//чтение файла
//парсинг
//кол-во анкет
//разделение по курсам
//Кол-во общажников