commit d327c1affd661599a8ef03ec7b6a4ebcff16de96
parent 83b387c059c98f46c86996f1cea306f29fe41c0e
Author: William Lindholm <a22willi@student.his.se>
Date: Thu, 16 Nov 2023 13:30:28 +0100
Changed from printf to cout.
Diffstat:
1 file changed, 9 insertions(+), 5 deletions(-)
diff --git a/Problem1/Problem1.cpp b/Problem1/Problem1.cpp
@@ -11,8 +11,8 @@
using namespace std;
-// Function prototype
-vector<int> bucketSort(vector<int> unsorted_vector);
+// Function prototypes
+vector<int> bucketSort(vector<int> unsortedVector);
string vectorToString(vector<int> vector);
int main()
@@ -20,8 +20,8 @@ int main()
vector<int> unsorted = { 41, 12, 53, 14, 5, 62, 7, 28, 9 };
vector<int> sorted = bucketSort(unsorted);
- printf("The unsorted vector: %s\nThe sorted vector: %s",
- vectorToString(unsorted), vectorToString(sorted));
+ cout << "The unsorted vector: " << vectorToString(unsorted) << endl;
+ cout << "The sorted vector: " << vectorToString(sorted) << endl;
return 0;
}
@@ -50,7 +50,11 @@ string vectorToString(vector<int> vector)
string output = "{";
for (int i = 0; i < vector.size(); i++)
{
- output += to_string(vector[i]) + ", ";
+ output += to_string(vector[i]);
+ if (i != vector.size() - 1)
+ {
+ output += ", ";
+ }
}
output += "}";