👍 −1 👎 |
Кто может решить программы на C++Написать программу подсчёта количества цифр в текстовом файле. Имя файла задаётся в командной строке
программирование обучение
Саша Стечкина
|
👍 −2 👎 |
#include <iostream>
#include <fstream> int main(int argc, char** argv){ if (argc != 2 ) { std::cout << "try: a.out \"file.txt\" " << std::endl; } else { char ch; std::fstream fin(argv[1], std::fstream::in); int num_of_numbers = 0; while (fin >> ch) { if (ch == '0' || ch == '1' || ch == '2' || ch == '3' || ch == '4' || ch == '5' || ch == '6' || ch == '7' || ch == '8' || ch == '9' ) num_of_numbers++; } if (num_of_numbers == 0 ) std::cout << " There is no digits in the file or file doesn't exist: " << num_of_numbers << std::endl; else if(num_of_numbers == 1 ) std::cout << " There is one digit in the file " << argv[1] << std::endl; else std::cout << " There are " << num_of_numbers << " digits in the file " << argv[1] << std::endl; } return 0; } |
👍 0 👎 |
https://ideone.com/hOTO1z — ссылочка на код с форматированием, сомневаюсь что оно тут есть. Если нет — код ниже |
👍 0 👎 |
При запуске программы в Делфи возникает ошибка "First chance exception at $7573C6E3. Exception class EVariantTypeCastError with message 'Could not convert variant of type (Null) into type (String)'. Process P_K_K.exe (2280)"
|
👍 0 👎 |
Visual BASIC
|
👍 −1 👎 |
Pascal
|