Đếm số lượng chữ số trong tâp tin vd: 8van 6ngan 400lan anh nho em--> KQ=5

#include<iostream> using namespace std; #include<fstream> /// câu 3 đếm số lượng chữ số trong tập tin int main() { ifstream input("input.txt", ios_base::in); if (!input) { cout << "\nKhong ton tai tap tin nay xin kiem tra lai cam on!"; system("pause"); return 0; } int diem = 0; while (!input.eof()) { char a; input >> a; if (a >= '0'&&a <= '9') { diem++; } } cout << "\nSo luong chu so trong tap tin la: "<<diem; system("pause"); return 0; }

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.