Нужно перевести задачу с С++ ** Paskal с объяснением ( дорого )#include using namespace...

0 голосов
52 просмотров

Нужно перевести задачу с С++ на Paskal с объяснением ( дорого )#include using namespace std;bool isletter(char c) { return c == 'A' || c == 'B' || c == 'C' || c == 'E' || c == 'H' || c == 'K' || c == 'M' || c == 'O' || c == 'P' || c == 'T' || c == 'X' || c == 'Y';}int main() { int n; cin >> n; for (int i = 0; i < n; ++i) { string s; cin >> s; if (s.length() == 6 && isletter(s[0]) && isdigit(s[1]) && isdigit(s[2]) && isdigit(s[3]) && isletter(s[4]) && isletter(s[5])) { cout << "Yes"; } else { cout << "No"; } cout << endl; } return 0;}


Информатика (16 баллов) | 52 просмотров
Дан 1 ответ
0 голосов

function isletter (c : Char) : boolean;

begin

case c of

'A': isletter := true;

'B': isletter := true;

'C': isletter := true;

'E': isletter := true;

'H': isletter := true;

'K': isletter := true;

'M': isletter := true;

'O': isletter := true;

'P': isletter := true;

'T': isletter := true;

'X': isletter := true;

'Y': isletter := true;

else

isletter := false;

end;


end;



function isdigit(c:char):boolean;

begin

IsDigit:=c in ['0'..'9']

end;



var

n : integer;

i : integer;

s : string;


begin

readln(n);

for i := 1 to n do

begin

readln(s);

if (length(s) = 6) and (isletter(s[1])) and (isdigit(s[2])) and (isdigit(s[3])) and (isdigit(s[4])) and (isletter(s[5])) and (isletter(s[6])) then

writeln('Yes')

else

writeln('No');

end;


end.


Чего объяснять та?) Переписал все точь в точь за исключением того, что в free pascal вроде как нет встроенной функции проверки char на цифра ли и пришлось писать самому. + Мне не оч нрав реализация isletter. Стремная, но так было в спрайтах, так что я молчу.

(310 баллов)