Объяснение:
A
class Parrot:
def __init__(self):
self.phrase = 'Привет, друзья!'
def say(self):
print(self.phrase)
p = Parrot()
p.say()
B
class Parrot:
def __init__(self, phrase):
self.phrase = phrase
def say(self):
print(self.phrase)
p1 = Parrot( "Гав!" )
p2 = Parrot( "Мяу!" )
p1.say()
p2.say()
С
class Parrot:
def __init__(self, phrase):
self.phrase = phrase
def say(self):
print(self.phrase)
def newText(self, phrase):
self.phrase = phrase
p = Parrot( "Гав!" )
p.say()
p.newText( "Мяу!" )
p.say()
D
class Parrot:
def __init__(self, phrase):
self.phrase = phrase
def say(self, count=1):
print(self.phrase*count)
def newText(self, phrase):
self.phrase = phrase
p = Parrot( "Гав!" )
p.say()
p.newText( "Мяу!" )
p.say( 3 )
Адресная сортировка
#include <iostream>
int main()
{
int value = 8;
int *ptr = &value;
std::cout << ptr << '\n';
std::cout << ptr+1 << '\n';
std::cout << ptr+2 << '\n';
std::cout << ptr+3 << '\n';
return 0;
}
Сортировка вставками
#include <iostream>
using namespace std;
int main()
{
const int N = 10;
int a[N] = { 12, 5, 3, 2, 45, 96, 6, 8, 11, 24 };
int buff = 0; // для хранения перемещаемого значения
int i, j; // для циклов
/ Начало сортировки /
for (i = 1; i < N; i++)
{
buff = a[i]; // запомним обрабатываемый элемент
// и начнем перемещение элементов слева от него
// пока запомненный не окажется меньше чем перемещаемый
for (j = i - 1; j >= 0 && a[j] > buff; j--)
a[j + 1] = a[j];
a[j + 1] = buff; // и поставим запомненный на его новое место
}
/ Конец сортировки /
for (int i = 0; i < N; i++) // вывод отсортированного массива
cout << a[i] << '\t';
cout << endl;
}
Думаю :)