78 lines
3.2 KiB
C++
78 lines
3.2 KiB
C++
// Parallel32.cpp : Этот файл содержит функцию "main". Здесь начинается и заканчивается выполнение программы.
|
||
//
|
||
|
||
#define _SILENCE_EXPERIMENTAL_FILESYSTEM_DEPRECATION_WARNING
|
||
#include <iostream>
|
||
#include <fstream>
|
||
#include <string>
|
||
#include <filesystem>
|
||
#include <experimental/filesystem>
|
||
using namespace std::experimental::filesystem::v1;
|
||
|
||
void countFileStats(const std::string& filePath) {
|
||
std::ifstream file(filePath);
|
||
if (!file.is_open()) {
|
||
std::cerr << "Unable to open file: " << filePath << std::endl;
|
||
return;
|
||
}
|
||
|
||
std::string line;
|
||
int lineCount = 0;
|
||
int wordCount = 0;
|
||
int charCount = 0;
|
||
|
||
while (std::getline(file, line)) {
|
||
lineCount++;
|
||
charCount += line.length();
|
||
|
||
// Count words in the line
|
||
bool inWord = false;
|
||
for (char c : line) {
|
||
if (std::isalpha(c)) {
|
||
if (!inWord) {
|
||
inWord = true;
|
||
wordCount++;
|
||
}
|
||
}
|
||
else {
|
||
inWord = false;
|
||
}
|
||
}
|
||
}
|
||
|
||
std::cout << "File: " << filePath << std::endl;
|
||
std::cout << "Number of lines: " << lineCount << std::endl;
|
||
std::cout << "Number of words: " << wordCount << std::endl;
|
||
std::cout << "Number of characters: " << charCount << std::endl;
|
||
|
||
file.close();
|
||
}
|
||
|
||
int main(int argc, char* argv[]) {
|
||
int count = 0;
|
||
int ver = std::atoi(argv[1]) * 125;
|
||
int cborder = 125;
|
||
if (std::atoi(argv[2]) == 1) {
|
||
cborder = 126;
|
||
}
|
||
while (count < cborder) {
|
||
std::string directoryPath = "C:\\Dod\\Dod1\\" + std::to_string(ver + count) + ".txt";
|
||
countFileStats(directoryPath);
|
||
count++;
|
||
}
|
||
|
||
system("pause");
|
||
return 0;
|
||
}
|
||
|
||
// Запуск программы: CTRL+F5 или меню "Отладка" > "Запуск без отладки"
|
||
// Отладка программы: F5 или меню "Отладка" > "Запустить отладку"
|
||
|
||
// Советы по началу работы
|
||
// 1. В окне обозревателя решений можно добавлять файлы и управлять ими.
|
||
// 2. В окне Team Explorer можно подключиться к системе управления версиями.
|
||
// 3. В окне "Выходные данные" можно просматривать выходные данные сборки и другие сообщения.
|
||
// 4. В окне "Список ошибок" можно просматривать ошибки.
|
||
// 5. Последовательно выберите пункты меню "Проект" > "Добавить новый элемент", чтобы создать файлы кода, или "Проект" > "Добавить существующий элемент", чтобы добавить в проект существующие файлы кода.
|
||
// 6. Чтобы снова открыть этот проект позже, выберите пункты меню "Файл" > "Открыть" > "Проект" и выберите SLN-файл.
|