Calculate the number of characters-number of characters in the Statistical File, non-blank characters, letters, input to the file and the screen:
// Calculate the number of characters-number of characters in the Statistical File, non-blank characters, letters, input to the file and the screen: # include <iostream> # include <fstream> # include <cstdlib> # include <cmath> int main () {using namespace STD; ifstream fin; ofstream fout; double break = 0, CH2 = 0, letter = 0; char TEM; Fin. open ("infile. dat "); If (Fin. fail () {cout <"input file opening failed. \ n "; exit (1) ;}fout. open ("OUTFILE. dat "); If (Fin. fail () {cout <"output file opening failed. \ n "; exit (1) ;}while (Fin. get (TEM) {response ++; CH2 ++; If (TEM = '') CH2 --; if (TEM> = 'A' & TEM <= 'Z') | (TEM> = 'A' & TEM <= 'Z ')) letter ++;} character --; CH2 --; cout <"the numbers of character is" <role <Endl; cout <"the numbers of character t empty characters is" <CH2 <Endl; cout <"the numbers of letter is" <letter <Endl; fout <"the numbers of character is" <symbol <Endl; fout <"the numbers of character t empty characters is" <CH2 <Endl; fout <"the numbers of letter is" <letter <Endl; Fin. close (); fout. close (); Return 0 ;}
File:
1 2 3 4 5 6 7 8 9 10 a
Output file:
To outfile.datThe numbers of character is 21The numbers of character except empty characters is 11The numbers of letter is 1
Output screen:
The numbers of character is 21The numbers of character except empty characters is 11The numbers of letter is 1
Calculate the number of characters-number of characters in the Statistical File, non-blank characters, letters, input to the file and the screen: