🗑️」 clean: cleanup things and slightly improved ex02/main.cpp

This commit is contained in:
y-syo
2025-09-01 16:00:41 +02:00
parent 7b47994ddd
commit f9c38cfe86
6 changed files with 37 additions and 28 deletions

View File

@@ -43,7 +43,7 @@ int main(int argc, char **argv)
for (size_t i = 0; i < vec.size() && i < 6; i++)
std::cout << vec[i] << " ";
if (vec.size() > 6)
std::cout << "[...]";
std::cout << "[...] (" << vec.size() << ")";
std::cout << std::endl;
clock_t startVec = clock();
@@ -58,9 +58,14 @@ int main(int argc, char **argv)
for (size_t i = 0; i < vec.size() && i < 6; i++)
std::cout << vec[i] << " ";
if (vec.size() > 6)
std::cout << "[...]";
std::cout << "[...] (" << vec.size() << ")";
std::cout << std::endl;
std::vector<int> sortedVec = vec;
std::sort(sortedVec.begin(), sortedVec.end());
if (vec != sortedVec)
throw std::runtime_error("it's not sorted, what-");
double vecTime = (double)(endVec - startVec) / CLOCKS_PER_SEC * 1000000.0;
double deqTime = (double)(endDeq - startDeq) / CLOCKS_PER_SEC * 1000000.0;