Вопрос школьника по предмету Информатика
Напишите программу, которая проверяет правильность имени переменной в языке Паскаль. Имя может содержать только латинские буквы (заглавные и строчные), цифры и знак подчёркивания, но не может начинаться с цифры.
Входные данные
На вход программы подаётся символьная строка, содержащая имя переменной.
Выходные данные
Программа должна вывести ответ ‘YES’, если строка представляет собой правильное имя переменной в языке Паскаль, и ‘NO’, если имя ошибочно.
Примеры
входные данные
Abc123
выходные данные
YES
входные данные
Abc[a!
выходные данные
NO
Pascal ABC 1.8 с использованием множеств
Ответ учителя по предмету Информатика
var s: string;
i: integer;
good: boolean;
begin
readln(s);
good := True;
if (s[1] in [‘0’..’9′]) then
good := False
else
begin
for i := 1 to length(s) do
if not ((s[i] in [‘a’..’z’]) or (s[i] in [‘A’..’Z’]) or (s[i] in [‘0’..’9′]) or (s[i] = ‘_’)) then
good := False;
end;
if (good) then
writeln(‘YES’)
else
writeln(‘NO’);
end.
Похожие вопросы от пользователей
1.Combine each pair of sentences. Use who or which.
My grandparents are really nice. I see them every weekend.
My grandparents, who I see every weekend, are really nice.
1 Mark is on holiday at the moment. I phoned him last night.
2 My new trainers are fantastic. Mum bought them yesterday.
3 Our teacher is from America. Everybody likes her.
4 The new Westlife song is very good. I’ve heard it on the
We use where for places, when for times, and whose for possession.
2.Complete the text. Use who, which, whose, where and when.
Once a year my family, who all live in Brighton, have a special picnic on the beach. My uncle Simon, (1)……house overlooks the sea, organizes everything. But last month, (2)……it rained almost every day, we couldn’t eat on the beach. So we went into the centre of town, (3)…… there are lots of restaurants and cafes. We chose ‘Fred’s cafe’, (4)……opened only a month ago. Their fish and chips were really good. My mum, (5)……hates cooking, liked ‘Fred’s cafe’ a lot. We now go there every Sunday!
Во сколько начались соревнования?