Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*Функция сортировки товаров по количеству*/
- void SortListQuan(List* First)
- {
- List* pointer = First;
- List* Headpointer = First;
- int count = 0, j, tmp;
- int* Quan = new int[n];
- for (int i = 0; i < n; i++)
- {
- Quan[i] = pointer->tovar.quantity;
- pointer = pointer->next;
- }
- for(int i = 0; i < n - 1; i++)
- for (int j = i + 1; j < n; j++)
- {
- if (Quan[i] == Quan[j])
- Quan[j] = 0;
- }
- for (int i = 0; i < n; i++)
- if (Quan[i] != 0)
- count++;
- j = 0;
- int* SortQuan = new int[count];
- for (int i = 0; i < n; i++)
- if (Quan[i] != 0)
- {
- SortQuan[j] = Quan[i];
- j++;
- }
- for(int i = 0; i < count; i++)
- for(int j = count - 1; j > i; j--)
- if (SortQuan[j - 1] < SortQuan[j])
- {
- tmp = SortQuan[j-1];
- SortQuan[j-1] = SortQuan[j];
- SortQuan[j] = tmp;
- }
- pointer = Headpointer;
- cout << "\n\n";
- cout << "Информация о всех товарах\n";
- cout << "\n";
- int temp = strlen("Название товара") + 1;
- if (temp < get_max_name(pointer) + 1)
- temp = get_max_name(pointer) + 1;
- /*Ячейки-заголовки*/
- cout << "Секция" << ' ';
- cout << setw(temp) << "Название товара" << ' ';
- cout << setw(10) << "Цена" << ' ';
- cout << "Количество" << ' ';
- cout << "Дата изготовления" << ' ';
- cout << "Срок хранения(мес.)" << ' ';
- /*Конец ячеек-заголовков*/
- cout << '\n';
- pointer = Headpointer;
- for (int i = 0; i < count - 1; i++)
- {
- for (int j = 0; j < n; j++)
- {
- if ((pointer->tovar.quantity <= SortQuan[i]) && (pointer->tovar.quantity > SortQuan[i + 1]))
- {
- cout << setw(6) << pointer->tovar.section << ' ';
- cout << setw(temp) << pointer->tovar.name << ' ';
- cout << setw(10) << setprecision(2) << fixed << pointer->tovar.price << ' ';
- cout << setw(10) << pointer->tovar.quantity << ' ';
- cout << setw(3) << pointer->tovar.date.day << ' ';
- cout << setw(8) << pointer->tovar.date.month << ' ';
- cout << setw(4) << pointer->tovar.date.year << ' ';
- cout << setw(18) << pointer->tovar.life << ' ';
- cout << '\n';
- }
- pointer = pointer->next;
- }
- pointer = Headpointer;
- }
- for (int j = 0; j < n; j++)
- {
- if ((pointer->tovar.quantity < SortQuan[count-2]) && (pointer->tovar.quantity >= SortQuan[count-1]))
- {
- cout << setw(6) << pointer->tovar.section << ' ';
- cout << setw(temp) << pointer->tovar.name << ' ';
- cout << setw(10) << setprecision(2) << fixed << pointer->tovar.price << ' ';
- cout << setw(10) << pointer->tovar.quantity << ' ';
- cout << setw(3) << pointer->tovar.date.day << ' ';
- cout << setw(8) << pointer->tovar.date.month << ' ';
- cout << setw(4) << pointer->tovar.date.year << ' ';
- cout << setw(18) << pointer->tovar.life << ' ';
- cout << '\n';
- }
- pointer = pointer->next;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement