Calculate the number of characters-number of characters in the Statistical File, non-blank characters, letters, input to the file and the screen:

Source: Internet
Author: User

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:

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.