Here's the code in question:
int participant_count; int budget; int hotel_count; int week_count;
int minimum_cost = INT32_MAX;
while (cin >> participant_count >> budget >> hotel_count >> week_count) {
int hotel_price;
int *available_bed_count = new int[week_count];
while (cin >> hotel_price) {
for (int i = 0; i < week_count; i++) {
scanf("%d", available_bed_count[i]);
if (available_bed_count[i] >= participant_count) {
minimum_cost = min(minimum_cost, (hotel_price * participant_count));
}
}
}
delete []available_bed_count;
}
and here's the textfile that I'm reading from. I've drawn an arrow to highlight the exact line that I cannot properly handle
3 1000 2 3
200
0 2 2 <---
300
27 3 20
5 2000 2 4
300
4 3 0 4
450
7 8 0 13
Unfortunately, my code breaks and nothing gets output to my file once the scanf function is reached and I don't know why. Could someone please tell me what I'm doing wrong? I'm thinking that there might be an issue with using 'cin' and 'scanf' together where I might be attempting to read from the same line that 'cin' read from, but I don't really know.