namespace ConsoleApp39
{
class Program
{
static void Main(string[] args)
{
Student[] students = new Student[3];
Student student = new Student();
for (int i = 0; i < students.Length; i++)
{
students[i].SetInfo();
}
student.GetInfo(students);
}
}
struct Student
{
string LastName;
string FirstName;
int GroupNumber;
int[] scores;
public void SetInfo()
{
Console.WriteLine("Введите фамилию: ");
LastName = Console.ReadLine();
Console.WriteLine("Введите имя: ");
FirstName = Console.ReadLine();
Console.WriteLine("Номер группы: ");
GroupNumber = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Выпишите оценки: ");
scores = new int[5];
int inp;
for (int i = 0; i < scores.Length; i++)
{
inp = Convert.ToInt32(Console.ReadLine());
scores[i] = inp;
}
}
public void GetInfo(Student[] students)
{
for (int i = 0; i < scores.Length; i++)
{
if (scores[i] <= 2)
{
Console.WriteLine($"Фамилия: {students[i].LastName}" +
$"\nИмя: {students[i].FirstName}" +
$"\nНомер группы: {students[i].GroupNumber}");
}
}
Array.Sort(scores);
}
}
}
for (int i = 0; i < scores.Length; i++)
namespace ConsoleApp39
{
class Program
{
static void Main(string[] args)
{
Student[] students = new Student[3];
for (int i = 0; i < students.Length; i++) students[i].SetInfo();
Student.GetInfo(students);
}
}
struct Student
{
string LastName;
string FirstName;
int GroupNumber;
int[] scores;
public void SetInfo()
{
Console.WriteLine("Last name: ");
LastName = Console.ReadLine();
Console.WriteLine("Name: ");
FirstName = Console.ReadLine();
Console.WriteLine("Number: ");
while (!int.TryParse(Console.ReadLine(), out GroupNumber)) {
Console.WriteLine("Only number allowed");
};
Console.WriteLine("Scores: ");
scores = new int[5];
int inp;
for (int i = 0; i < scores.Length; i++)
{
while (!int.TryParse(Console.ReadLine(), out inp))
{
Console.WriteLine("Only number allowed");
};
scores[i] = inp;
}
}
public static void GetInfo(Student[] students)
{
foreach (var student in students)
{
for (int i = 0; i < student.scores.Length; i++)
{
if (student.scores[i] <= 2)
{
Console.WriteLine($"Last name: {student.LastName}\n name: {student.FirstName}\n Group: {student.GroupNumber}");
}
}
}
}
}
}