Advertisement
Guest User

Untitled

a guest
Apr 27th, 2017
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 3.10 KB | None | 0 0
  1. var
  2.   i, line: integer;
  3.   c1, c2, c3: char;
  4.   b1, b2, b3: boolean;
  5.   procedure checkFIO(s: string);
  6.   begin
  7.   read(c1);
  8.   if ((c1 < 'А') or (c1 > 'Я')) and ((c1 < 'а') or (c1 > 'я')) then
  9.     b1 := true
  10.   else if ((c1 >= 'а') and (c1 <= 'я')) then
  11.     writeln(s, ' с маленькой буквы');
  12.   read(c1);
  13.   while c1 <> ' ' do
  14.   begin
  15.     if (c1 >= 'А') and (c1 < 'Я') then
  16.       b2 := true
  17.     else if (c1 < 'а') or (c1 > 'я') then
  18.       b1 := true;
  19.     read(c1);
  20.   end;
  21.   if b2 then
  22.     writeln('В строке ', line, ' ', s, ' содержит заглавние буквы, не на первой позиции');
  23.   if b1 then
  24.     writeln('В строке ', line, ' ', s, ' содержит недопустимые символы');
  25.   end;
  26.  
  27.   procedure checkNuberSlash(s: string; l, r: integer);
  28.   begin
  29.       b1 := false;
  30.   b2 := false;
  31.   i := 0;
  32.   read(c1);
  33.   while c1 <> '/' do
  34.   begin
  35.     if c1 = ' ' then
  36.       b2 := true
  37.     else if (c1 < '0') or (c1 > '9') then
  38.       b1 := true
  39.     else
  40.       i := i * 10 + ord(c1) - 48;
  41.     read(c1);
  42.   end;
  43.   if b2 then
  44.     writeln('В строке ', line, ' ', 'В дате не 3 числа');
  45.   if b1 then
  46.     writeln('В строке ', line, ' ', s, ' содержит недопустимые символы')
  47.   else if not ((i >= l) and (i <= r)) then
  48.     writeln('В строке ', line, ' ', 'Недопустимый ', s);
  49.   end;
  50.  
  51. procedure checkFourNumbers(s: string);
  52. var
  53.   i: integer;
  54. begin
  55.   b1 := false;
  56.   for i := 1 to 4 do
  57.   begin
  58.     read(c1);
  59.     if (c1 = ' ') or (ord(c1) = 13) or ((eof(input)) and (i <> 4)) then
  60.     begin
  61.       writeln('В строке ', line, ' ', s, ' содержит неверное колличество цифр');
  62.       Exit;
  63.     end;
  64.     if not ((c1 >= '0') and (c1 <= '9')) then
  65.       b1 := true;
  66.   end;
  67.   if b1 then
  68.     writeln('В строке ', line, ' ', s, ' содержит недопустимые символы');
  69.   if not eof(input) then  
  70.     read(c1);
  71. end;
  72.  
  73. begin
  74.   assign(input, 'input.txt');
  75.   assign(output, 'output.txt');
  76.   reset(input);
  77.   rewrite(output);
  78.  
  79.   line := 1;
  80.   while not eof(input) do
  81.   begin
  82.   b1 := false;
  83.   b2 := false;
  84.   checkFIO('Фамилия');
  85.   checkFIO('Имя');
  86.   checkFIO('Отчество');
  87.   read(c2, c3);
  88.   if c3 = ' ' then
  89.   begin
  90.   if (c2 = 'М') or (c2 = 'Ж') then
  91.     writeln('В строке ', line, ' ', 'Пол с заглавной буквы')
  92.   else if not ((c2 = 'м') or (c2 = 'ж')) then
  93.     writeln('В строке ', line, ' ', 'Неверный символ пола');
  94.   end
  95.   else
  96.   begin
  97.     writeln('В строке ', line, ' ', 'Неверное колличество символов пола');
  98.     while c1 <> ' ' do
  99.       read(c1);
  100.   end;
  101.  
  102.   checkNuberSlash('День', 1, 31);
  103.   if not b2 then
  104.     checkNuberSlash('Месяц', 1, 12);
  105.   if not b2 then
  106.     checkFourNumbers('Год');
  107.   checkFourNumbers('Ид');//Не ебу как назвать 4 числа последнии, предположим это ид
  108.   line := line + 1;
  109.   readln();
  110.   end;
  111. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement