Question
In C++ i am having trouble with my input.txt file, i don't have any errors with my main driver program. Just need help adding my
In C++ i am having trouble with my input.txt file, i don't have any errors with my main driver program.
Just need help adding my input.txt file to the main program.
Here is my code along with the input.txt file to be added. results still printed to screen. thank you
input.txt
3
10
6
5 10 2 5 4 4
10
20
4 4 4 4 4 4 4 4 4 4 6 6 6 6 6 6 6 6 6 6
10
4
3 8 2 7
C++ code below:
// C++ program to find number of bins required using // Best fit algorithm. #include
// C++ program to find number of bins required using // First Fit Decreasing algorithm. #include
// Returns number of bins required using first fit // decreasing offline algorithm int firstFitDec(int weight[], int n, int c) { // First sort all weights in decreasing order sort(weight, weight+n, std::greater
// Driver program int main() { int weight[] = {3, 8, 2, 7 }; int c = 10; int n = sizeof(weight) / sizeof(weight[0]); cout << "first fit: " << firstFit (weight, n, c); cout << "first fit dec: " << firstFitDec(weight, n, c); cout << "Number of bins required in Best Fit: " << bestFit(weight, n, c); return 0; }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started