Перенос страниц

This commit is contained in:
Alexander Zhirov 2023-03-05 15:30:34 +03:00
parent 4d57446057
commit 4c954c9186
129 changed files with 14 additions and 15 deletions

View file

@ -0,0 +1,15 @@
import std.stdio;
void main()
{
auto array = [0, 2, 4, 6, 8, 10];
array = array[0 .. $ - 2];
// Су­же­ние спра­ва на два эле­мен­та
assert(array == [0, 2, 4, 6]);
array = array[1 .. $];
// Су­же­ние сле­ва на один эле­мент
assert(array == [2, 4, 6]);
array = array[1 .. $ - 1];
// Су­же­ние с обе­их сто­рон
assert(array == [4]);
}

View file

@ -0,0 +1,18 @@
import std.conv, std.stdio;
int main(string[] args)
{
// Избавиться от имени программы
args = args[1 .. $];
while (args.length >= 2)
{
if (to!int(args[0]) != to!int(args[$ - 1]))
{
writeln("не палиндром");
return 1;
}
args = args[1 .. $ - 1];
}
writeln("палиндром");
return 0;
}