сделать непрерывное преобразование заглавных в строчные, сейчас программа преобразует только на выводе #include
#include
#include
int main() {
setlocale(LC_ALL, "Russian");
char str[500];
int i;
printf("Введите строку:\n");
fgets(str, 500, stdin);
for (i = 0; i < strlen(str); i++) {
if (isupper(str[i]))
str[i] = tolower(str[i]);
}
printf("\nПреобразованная строка: %s", str);
return 0;
}
uses GraphABC;
procedure Sun(x, y: integer);
begin
var c := 8;
for var j := 1 to 100 do
begin
var r := 15 * c;
var k := 0;
if j mod 2 = 0 then k := 20;
for var i := 0 to c do
begin
Brush.Color := RGB(230 - k, 230 - k, 0);
Circle(x, y, r);
k := k + 15;
r := r - 15;
sleep(100);
end;
end;
end;
procedure House(x, y: integer);
begin
Brush.Color := clBrown;
Pen.Color := clBurlyWood;
var house_width := 300;
var house_height := 300;
var count := 10;
var step := round(house_width / count);
FillRectangle(x, y, x + house_width, y + house_height);
var xx := x;
for var i := 1 to count - 1 do
begin
xx := xx + step;
Line(xx, y, xx, y + house_height);
end;
Brush.Color := clGray;
FillRectangle(x + 100, y + 100, x + 200, y + 210);
Brush.Color := clYellow;
FillRectangle(x + 105, y + 105, x + 195, y + 150);
Brush.Color := clRed;
FillRectangle(x + 105, y + 155, x + 150, y + 205);
Brush.Color := clBlue;
FillRectangle(x + 155, y + 155, x + 195, y + 205);
MoveTo(x + house_width div 2, y - 80);
LineTo(x + house_width, y, Pen.Color);
LineTo(x, y, Pen.Color);
LineTo(x + house_width div 2, y - 80, Pen.Color);
FlooDfill(x + house_width div 2, y - 10, clOlive);
Brush.Color := clRed;
Circle(x + house_width div 2, y - 35, 30);
end;
procedure Turtoise(x, y: integer);
begin
Brush.Color := clGreen;
Pen.Color := clGreen;
FillRectangle(x + 5, y + 15, x - 20, y + 24);
FillRectangle(x + 50, y, x + 30, y + 70);
FillRectangle(x + 100, y, x + 120, y + 70);
FillCircle(x + 170, y, 30);
Brush.Color := clWhite;
FillCircle(x + 180, y - 20, 10);
Brush.Color := clBlack;
FillCircle(x + 182, y - 18, 2);
Brush.Color := clRed;
FillRectangle(x + 180, y, x + 200, y + 4);
Brush.Color := clBrown;
FillEllipse(x, y - 10, x + 150, y + 50);
end;
begin
Window.Init(0, 0, 1920, 1000, clBlue);
Brush.Color := clLimeGreen;
Rectangle(0, 580, 1920, 1018);
House(700, 380);
Turtoise(300, 600);
Turtoise(900, 750);
Sun(1200, 200);
end.
def LineUpArraySize(num)
cur_size = 4
while num > cur_size
cur_size = 2 * cur_size + 8
end
cur_size = 2 * cur_size + 8
end
def getSpiralNeighbours(num)
a = []
a[0] = [0, 0]
a[1] = [-1, 1]
moves = [[1, 0], [0, -1], [-1, 0], [0, 1]]
move_direction = 0
side_size = 2
cur_size = 1
cycle = 1
mode_direction = 0
for i in 2..LineUpArraySize(num)
new_num = Array.new(2)
new_num[0] = a.last[0] + moves[move_direction][0]
new_num[1] = a.last[1] + moves[move_direction][1]
a[i] = new_num
# p new_num
cur_size += 1
if cur_size == side_size
cur_size = 1
move_direction = (move_direction + 1) % 4
side_size += 1 if move_direction % 2 == 0
cycle += 1 if move_direction == 0
end
end
a.each_with_index do |i,x|
p [x, i] if (i[0]-a[num][0]).abs <= 1 and (i[1]-a[num][1]).abs <= 1
end
end
getSpiralNeighbours(1090)
Вывод (числа и условные координаты)
[962, [15, 16]]
[1089, [15, 17]]
[1090, [16, 17]]
[1091, [16, 16]]
[1224, [15, 18]]
[1225, [16, 18]]
[1226, [17, 18]]
[1227, [17, 17]]
[1228, [17, 16]]