function parseObject(object, name=undefined, result=[]) {
for (let key in object) {
if (object.hasOwnProperty(key)) {
if (key === 'show' && object['show']) {
result.push(name);
}
if (Object.prototype.toString.call(object[key]) === '[object Object]') {
parseObject(object[key], name ? `${name}.${key}` : `${key}`, result);
}
}
}
return result;
}
console.log(parseObject(obj)); // [ 'obj1', 'obj2', 'obj2.child.child2', 'obj3' ]
[ 1, 1, 1, 1, 1, 1 ]
)[ 1, 1, 1, 1, 1, 1 ]
...
[ 5, 5, 5, 5, 2, 1 ]
[ 5, 5, 5, 5, 5, 5 ]
и уменьшат последний элемент. void bubble_sort(int array[SIZE])
{
int transfer = 0;
int comparison = 0;
cout << "\nпузырьковая сортировка" << endl;
for (int i = 0; i < SIZE-1 ; i++)
{
for (int j = SIZE-2; j >= i; j--)
{
comparison++;
if (array[j] > array[j+1])
{
int temp = array[j];
array[j] = array[j+1];
array[j+1] = temp;
transfer++;
}
}
}
cout << "СРАВНЕНИЕ " << comparison << endl;
cout << "ПЕРЕСЫЛКА " << transfer << endl;
}
добавить скажем 10 строчек в БД
не известное количество переменных
$ npm cache clean --force
$ npm install --force --verbose --no-bin-links
$ npm install pug@2.0.3
$ npm install pug-cli@1.0.0-alpha6 -g
$ ln -s /usr/local/lib/nodejs/node-v11.1.0/bin/pug /usr/bin/pug
$ pug -V
pug version: 2.0.3
pug-cli version: 1.0.0-alpha6
class Rectangle(object):
def __init__(self, x, y, w, h):
self.x1 = x
self.x2 = x + w
self.y1 = y
self.y2 = y + h
def is_involved(self, other):
if all([other.x1 <= self.x1,
other.y1 <= self.y1,
other.x2 >= self.x2,
other.y2 >= self.y2]):
return True
return False
def is_intersected(self, other):
if any([all([other.x1 <= self.x1 <= other.x2, other.y1 <= self.y1 <= other.y2]),
all([other.x1 <= self.x2 <= other.x2, other.y1 <= self.y1 <= other.y2]),
all([other.x1 <= self.x1 <= other.x2, other.y1 <= self.y2 <= other.y2]),
all([other.x1 <= self.x2 <= other.x2, other.y1 <= self.y2 <= other.y2])]):
return True
return False
print("Rectangle 1:")
rect1 = Rectangle(int(input("x = ")), int(input("y = ")), int(input("width = ")), int(input("height = ")))
print()
print("Rectangle 2:")
rect2 = Rectangle(int(input("x = ")), int(input("y = ")), int(input("width = ")), int(input("height = ")))
print()
print('а) Принадлежат ли все точки первого прямоугольника второму:')
print(rect2.is_involved(rect1))
print('б) Принадлежат ли все точки одного из прямоугольников другому:')
print(rect2.is_involved(rect1) or rect1.is_involved(rect2))
print('в)* Пересекаются ли эти прямоугольники:')
print(rect2.is_intersected(rect1) or rect1.is_intersected(rect2))
ld
желательно объявлять перед циклом.print
неправильный отступ.input_value = int(input())
max_number = 0
while (input_value > 0):
current_number = input_value % 10
if (max_number < current_number):
max_number = current_number
input_value //= 10
print(max_number)