Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- namespace EGN
- {
- class Program
- {
- private static long CalculateYears(long n)
- {
- //ПО месеца се разбира коя година (<1900||1900<=1999||>1999) е роден човека
- //+20
- //+40
- var month = 0;
- var temp = n;
- if (n<12)
- {
- for (int i = 1; i <= n; i++)
- {
- if (i == temp)
- {
- month = i;
- break;
- }
- }
- }
- if (n>21 && n <= 32)
- {
- for (int i = 21; i <= n; i++)
- {
- var minusTwenty = i - 20;
- if (i == temp)
- {
- month = minusTwenty;
- break;
- }
- }
- }
- if (n>=41 && n<=52)
- {
- for (int i = 41; i <= n; i++)
- {
- var minusFourty = i - 40;
- if (i == temp)
- {
- month = minusFourty;
- break;
- }
- }
- }
- return month;
- }
- static void Main(string[] args)
- {
- long input = long.Parse(Console.ReadLine());
- long result = 0;
- long res = 0;
- long newTemp = input;
- long temporal = 0;
- long tre = input;
- for (int j = 0; j < 5; j++)
- {
- temporal = tre % 100;
- tre /= 100;
- }
- //0044285021
- if (temporal!=0)
- {
- List<long> egnn = new List<long>();
- List<long> controlNumber = new List<long>();
- while (newTemp > 0)
- {
- res = newTemp % 10;
- controlNumber.Add(res);
- newTemp /= 10;
- }
- long[] cont = { 0, 6, 3, 7, 9, 10, 5, 8, 4, 2 };
- long contrMulty = 0;
- for (int i = 1; i < controlNumber.Count; i++)
- {
- contrMulty += (cont[i] * controlNumber[i]);
- }
- long controla = 0;
- if (contrMulty % 11 == 10)
- {
- controla = 0;
- }
- else
- {
- controla = contrMulty % 11;
- }
- Console.WriteLine("Контролно число: " + controla);
- Console.Write("Роден:");
- while (input > 0)
- {
- result = input % 100;
- egnn.Add(result);
- input /= 100;
- }
- var checkForYear = egnn[3];
- //
- var year = CalculateYearsPeint(egnn);
- Console.WriteLine(year);
- Console.WriteLine($"Възраст/разлика м/у датите в години: {DateTime.Now.Year} => {DateTime.Now.Year - year}");
- //
- var month = CalculateYears(egnn[3]);
- Console.Write("Month: ");
- switch (month)
- {
- case 1: Console.WriteLine("Jan"); break;
- case 2: Console.WriteLine("Feb"); break;
- case 3: Console.WriteLine("March"); break;
- case 4: Console.WriteLine("April"); break;
- case 5: Console.WriteLine("May"); break;
- case 6: Console.WriteLine("June"); break;
- case 7: Console.WriteLine("July"); break;
- case 8: Console.WriteLine("August"); break;
- case 9: Console.WriteLine("Sept"); break;
- case 10: Console.WriteLine("Oct"); break;
- case 11: Console.WriteLine("Novem"); break;
- case 12: Console.WriteLine("Dec"); break;
- }
- if (egnn[2] > 0 && egnn[2] < 32)
- {
- var sufix = "Ден: ";
- Console.WriteLine(sufix + egnn[2]);
- }
- var sexcontrol = egnn[0] / 10;
- if (sexcontrol % 2 == 0)
- {
- Console.WriteLine("Пол: Мъж");
- }
- else
- {
- Console.WriteLine("Пол: Жена");
- }
- }
- else
- {
- List<long> egnn = new List<long>();
- List<long> controlNumber = new List<long>();
- while (newTemp > 0)
- {
- res = newTemp % 10;
- controlNumber.Add(res);
- newTemp /= 10;
- }
- long[] cont = { 0, 6, 3, 7, 9, 10, 5, 8, 4, 2 };
- long contrMulty = 0;
- for (int i = 1; i < controlNumber.Count; i++)
- {
- contrMulty += (cont[i] * controlNumber[i]);
- }
- long controla = 0;
- if (contrMulty % 11 == 10)
- {
- controla = 0;
- }
- else
- {
- controla = contrMulty % 11;
- }
- Console.WriteLine("Контролно число: " + controla);
- Console.Write("Роден:");
- while (input > 2)
- {
- result = input % 100;
- egnn.Add(result);
- input /= 100;
- }
- var year = TryCalcYear(egnn);
- Console.WriteLine(year);
- Console.WriteLine($"Възраст/разлика м/у датите в години: {DateTime.Now.Year} => {DateTime.Now.Year - year}");
- var month = CalculateYears(egnn[3]);
- Console.Write("Month: ");
- switch (month)
- {
- case 1: Console.WriteLine("Jan"); break;
- case 2: Console.WriteLine("Feb"); break;
- case 3: Console.WriteLine("March"); break;
- case 4: Console.WriteLine("April"); break;
- case 5: Console.WriteLine("May"); break;
- case 6: Console.WriteLine("June"); break;
- case 7: Console.WriteLine("July"); break;
- case 8: Console.WriteLine("August"); break;
- case 9: Console.WriteLine("Sept"); break;
- case 10: Console.WriteLine("Oct"); break;
- case 11: Console.WriteLine("Novem"); break;
- case 12: Console.WriteLine("Dec"); break;
- }
- if (egnn[2] > 0 && egnn[2] < 32)
- {
- var sufix = "Ден: ";
- Console.WriteLine(sufix + egnn[2]);
- }
- var sexcontrol = egnn[0] / 10;
- if (sexcontrol % 2 == 0)
- {
- Console.WriteLine("Пол: Мъж");
- }
- else
- {
- Console.WriteLine("Пол: Жена");
- }
- }
- Console.WriteLine(DateTime.Now.Year);
- }
- private static int TryCalcYear(List<long> egnn)
- {
- var checkForYear = egnn[3];
- var years = 0;
- if (checkForYear > 21 && checkForYear <= 32)
- {
- years += 1800;
- // Console.WriteLine(years);
- }
- else if (checkForYear >= 41 && checkForYear <= 52)
- {
- years += 2000;
- // Console.WriteLine(years);
- }
- else
- {
- years += 1900;
- //Console.WriteLine(years);
- }
- return years;
- }
- private static long CalculateYearsPeint(List<long> egnn)
- {
- var checkForYear = egnn[3];
- if (checkForYear > 21 && checkForYear <= 32)
- {
- egnn[4] += 1800;
- // Console.WriteLine(egnn[4]);
- }
- else if (checkForYear >= 41 && checkForYear <= 52)
- {
- egnn[4] += 2000;
- //Console.WriteLine(egnn[4]);
- }
- else
- {
- egnn[4] += 1900;
- //Console.WriteLine(egnn[4]);
- }
- return egnn[4];
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement