1234567891011121314151617181920212223242526272829303132 |
- //1
- Console.WriteLine("Введите год рождения: ");
- int year1 = int.Parse(Console.ReadLine());
- for (int year = 1900; year < 2000; year++)
- {
- for (int month = 1; month <= 12; month++)
- {
- for (int day = 1; day <= DateTime.DaysInMonth(year, month); day++)
- {
- DateTime date = new DateTime(year, month, day);
- int age = year1 - year;
- int sum1 = CalculateSumOfSquares(year) - (day * day);
- if (sum1 == age)
- {
- Console.WriteLine("Дата рождения по свойству Васи: " + date.ToShortDateString());
- }
- }
- }
- }
- static int CalculateSumOfSquares(int year)
- {
- int sum = 0;
- foreach (char c in year.ToString())
- {
- sum += int.Parse(c.ToString()) * int.Parse(c.ToString());
- }
- return sum;
- }
|