Advertisement
GEEG_IT

Untitled

Apr 6th, 2020
216
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.63 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. namespace _4
  4. {
  5.     class Person
  6.     {
  7.  
  8.         public string LastName;
  9.         public string FirstName;
  10.         public int Age;
  11.     }
  12.  
  13.     class Program
  14.     {
  15.  
  16.         static void Main(string[] args)
  17.         {
  18.             List<Person> people = new List<Person>();
  19.             string name = " ";
  20.             string srname = " ";
  21.             int age;
  22.             while (srname != "exit")
  23.             {
  24.              
  25.                 Console.Write("Введите фамилию: ");
  26.                 srname = Console.ReadLine();
  27.                 if (srname != "exit")
  28.                 {
  29.                     Console.Write("Введите имя: ");
  30.  
  31.                     name = Console.ReadLine();
  32.                     Console.Write("Введите возраст: ");
  33.                     age = Convert.ToInt32(Console.ReadLine());
  34.                     Person person = new Person();
  35.                     person.LastName = srname;
  36.                     person.FirstName = name;
  37.                     person.Age = age;
  38.                     people.Add(person);
  39.                    
  40.  
  41.                 }
  42.  
  43.             }
  44.             Console.Write("Введите возраст: ");
  45.             int agev = Convert.ToInt32(Console.ReadLine());
  46.             for (int i = 0; i < people.Count; i++)
  47.             {
  48.                 if (people[i].Age >= agev)
  49.                 {
  50.                     Console.WriteLine(people[i].FirstName + " " + people[i].LastName +" "+people[i].Age);
  51.                 }
  52.                
  53.             }
  54.             Console.WriteLine();
  55.            
  56.         }
  57.     }
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement