using System using System Collections Generic using System Linq using

  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
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace WindowsFormsApplication2
{
class Lab3
{
private const int N = 3;
private string date;
public int counter = 0;
char[] str = new char[11];
Person[] a = new Person[N];
Random rand = new Random();
public struct idk
{
public string name;
public string surname;
public string fth;
}
public struct Date
{
public int year;
public int mth;
public int day;
}
public struct Person
{
public idk fio;
public int ChildAmount;
public string[] ChildBrth;
}
string creator_fio(char[] str1)
{
string Newtext = "";
for (int i = 0; i < 6; i++)
{
int x = rand.Next(97,122);
str1[i] = Convert.ToChar(x);
// str1 += str1[i];
str1[0] = Convert.ToChar(x - 32);
}
return Convert.ToString(str1);
}
string creator_date(string str1)
{
Date idk;
int year, mth, day;
year = rand.Next(1990, 2013);
mth = rand.Next(1,12);
if ((mth == 2) && (year % 4 == 0))
day = rand.Next(1,28);
else if ((mth % 2 == 0) && (mth != 2))
day = rand.Next(1, 30);
else
day = rand.Next(1, 31);
str1 = Convert.ToString(idk.year = year) + '.';
str1 += Convert.ToString(idk.mth = mth) + '.';
str1 += Convert.ToString(idk.day = day);
return str1;
}
int calculator(string str1)
{
int i = 0, cnt = 0;
int[] date = new int[3];
while ((str1[i] != '.') && (i < 3))
{
date[i] = Convert.ToInt32(str1);
i++;
}
if ((date[0] <= 1996) && (date[1] <= 12) && (date[2] <= 12))
cnt++;
return cnt;
}
public Lab3()
{
for (int i = 0; i < N; i++)
{
//int counter = 0;
int x = rand.Next(1,5);
a[i].fio.name = creator_fio(str);
a[i].fio.surname = creator_fio(str);
a[i].fio.fth = creator_fio(str);
a[i].ChildAmount = x;
for (int j = 0; j < x; j++)
{
a[i].ChildBrth[j] += creator_date(date);
counter += calculator(a[i].ChildBrth[j]);
}
}
}
public string print(int cnt)
{
string NewText = "";
NewText += cnt;
return NewText;
}
}
}