Предмет:
ИнформатикаАвтор:
harmonyvoid FiveProductLeast(const char* fn) {
Handmade a, b;
int n = 0;
int amount = AmountTovar(fn);
int* least_nums = new int[5]{ INT_MAX, INT_MAX, INT_MAX, INT_MAX, INT_MAX };
fopen_s(&handmade_store, fn, "rb");
while (fread(&a, sizeof(Handmade), 1, handmade_store)) {
int a_num = a.num;
bool least_found = false;
for (int i = 0; i < 5; i++) {
if (a_num < least_nums[i]) {
least_nums[i] = a_num;
least_found = true;
break;
}
}
if (least_found) {
// Sort least_nums array in ascending order
std::sort(least_nums, least_nums + 5);
}
}
fclose(handmade_store);
fopen_s(&handmade_store, fn, "rb");
while (fread(&a, sizeof(Handmade), 1, handmade_store)) {
if (a.num <= least_nums[4]) { // Only print if num is one of the 5 least
n++;
Hat();
cout << "| " << setw(3) << right << n << " "
<< "| " << setw(14) << left << a.code << " "
<< "| " << setw(26) << left << a.tovar << " "
<< "| " << setw(13) << left << a.category << " "
<< "| " << setw(17) << left << a.oznaka << " "
<< "| " << setw(8) << right << fixed << setprecision(3) << a.len << " "
<< "| " << setw(5) << right << a.num << " "
<< "| " << setw(17) << left << a.country << " "
<< "| " << setw(9) << right << setprecision(2) << a.cost << " "
<< " |" << endl;
Line();
}
}
fclose(handmade_store);
delete[] least_nums;
}
Автор:
theresaumghДобавить свой ответ
Предмет:
МатематикаАвтор:
sophia65Ответов:
Смотреть
Предмет:
МатематикаАвтор:
bonesОтветов:
Смотреть
Предмет:
Українська літератураАвтор:
jairashleyОтветов:
Смотреть