a = int(input())
for i in range(a):
b = input()
c = 0
d = True
e = 0
f = False
g = False
h = '\''
for j in b:
if j == '#' and not f:
g = True
break
elif j != ' ':
if d:
print(' ' * c, end='')
elif c > 0:
print(' ', end='')
print(j, end='')
if(j == '\"' or j == '\'') and e % 2 == 0:
if f and j == h:
else:
f = True
h = j
if f:
d = False
if j == '\\':
e += 1
c += 1
r = j == ' '
if g and c > 1:
if i < a - 1:
print()
1
Объяснение:
var
x, y, t, c, n, k: integer;
a: array [1..10] of integer;
begin
for t := 1 to 10 do
a[t] := 0;
read(x, y);
t := x;
while (t <> 0) do
c += 1;
t := t div 10;
end;
k := 1;
for t := 1 to c do
k *= 10;
while (x <> 0) do
n := y;
t := x div k;
while (n <> 0) do
c := n mod 10;
n := n div 10;
if (c = t) and (a[c + 1] = 0) then
write(t, ' ');
a[c + 1] += 1;
break;
x := x mod k;
k := k div 10;
end.
a = int(input())
for i in range(a):
b = input()
c = 0
d = True
e = 0
f = False
g = False
h = '\''
for j in b:
if j == '#' and not f:
g = True
break
elif j != ' ':
if d:
print(' ' * c, end='')
elif c > 0:
print(' ', end='')
c = 0
print(j, end='')
if(j == '\"' or j == '\'') and e % 2 == 0:
if f and j == h:
f = False
else:
f = True
h = j
if f:
d = True
else:
d = False
if j == '\\':
e += 1
else:
e = 0
else:
c += 1
r = j == ' '
if g and c > 1:
print(' ', end='')
if i < a - 1:
print()
1
Объяснение:
var
x, y, t, c, n, k: integer;
a: array [1..10] of integer;
begin
for t := 1 to 10 do
a[t] := 0;
read(x, y);
t := x;
while (t <> 0) do
begin
c += 1;
t := t div 10;
end;
k := 1;
for t := 1 to c do
k *= 10;
while (x <> 0) do
begin
n := y;
t := x div k;
while (n <> 0) do
begin
c := n mod 10;
n := n div 10;
if (c = t) and (a[c + 1] = 0) then
begin
write(t, ' ');
a[c + 1] += 1;
break;
end;
end;
x := x mod k;
k := k div 10;
end;
end.