M
Size: a a a
R
R
RM
RM
RM
RM
SS
А
aменьший индекс
bбольший индекс
c = a + 0.5 *(b - a)
cэто индекс между ними
A
А
C
А
#include <iostream>
using namespace std;
struct Coords
{
int data;
Coords *next;
};
struct List
{
~List()
{
while (m_head)
{
Coords *p = m_head;
m_head = m_head->next;
delete p;
}
}
void add_end(int d)
{
Coords *node = new Coords;
node->data = d;
node->next = nullptr;
if (!m_head)
m_head = m_last = node;
else
{
m_last->next = node;
m_last = node;
}
++m_size;
}
void print_list() const
{
for (Coords *p = m_head; p; p = p->next)
cout << p->data << " ";
std::cout << std::endl;
}
Coords *m_head = nullptr;
Coords *m_last = nullptr;
size_t m_size = 0;
};
int main()
{
List list1;
List list2;
int n1;
cout << "Enter amount of element from List1: "; cin >> n1;
for (int i = 0; i < n1; i++)
{
int L1;
cout << " Enter " << i + 1 << " element: ";
cin >> L1;
list1.add_end(L1);
}
cout << "Enter amount of element from List2: "; cin >> n1;
for (int i = 0; i < n1; i++)
{
int L1;
cout << " Enter " << i + 1 << " element: ";
cin >> L1;
list2.add_end(L1);
}
list1.print_list();
list2.print_list();
system("pause");
return 0;
}
А
А
D