Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
210CT_Lab_Solutions_CPP/W1.cpp
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
51 lines (45 sloc)
1.25 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include "header/W1.h" | |
int main() { | |
// Task 1 | |
Task1 tsk1; | |
string strA = tsk1.input_first_str(); | |
string strB = tsk1.input_second_str(); | |
tsk1.combine_strings(strA, strB); | |
// Task 2 | |
Task2 tsk2; | |
tsk2.is_armstrong(371); | |
// Task 3 | |
Task3 tsk3; | |
map<int, string> results; | |
for(int i = 0; i < 2000; i++) { | |
string b = tsk3.is_armstrong(i); | |
if(b == "True") { | |
results[i] = b; | |
} | |
} | |
tsk3.export_file(results); | |
// Task 4 | |
Task4 tsk4; | |
int n = 20; | |
int d = 100000; | |
cout << tsk4.check_division(n, tsk4.factorial_a(n), d); | |
// Task 5 | |
Task5 tsk5; | |
cout << "What is the total value (£) of materials the vehicle can carry? " << endl; | |
cin >> tsk5.max_load; | |
tsk5.input_materials(); | |
tsk5.sort_by_price(); | |
for(int i = 0; i < tsk5.n; i++) { | |
if (tsk5.max_load <= 0) { | |
break; | |
} | |
tsk5.materials[i].loaded = min(tsk5.max_load, tsk5.materials[i].stock); | |
tsk5.max_load -= tsk5.materials[i].loaded; | |
} | |
cout << "Load Composition of the Vehicle" << endl; | |
for(int i = 0; i < tsk5.n; i++) { | |
cout << "Loaded £" << tsk5.materials[i].loaded << " (" << tsk5.materials[i].loaded / tsk5.materials[i].price << "kg) of " << tsk5.materials[i].name << endl; | |
} | |
return 0; | |
} |