C + + Experiment 5--The number of letters (large/lowercase), number of numbers, and number of other characters in the output string.

Source: Internet
Author: User

I. Questions and codes

/* File Name: * Author: Geng Ting aniseeds Estates * Completion Date: May 3, 2016 * version number: v1.0 * Description of task and solution method part: Count the number of letters in the output string (large/lowercase), number of digits and number of other characters. * Input Description: * Problem Description: * Program output: * Problem Analysis: * Algorithm design: */#include <iostream> #include <cstdio> using NAMESP    Ace STD;        int main () {char str[50];        int i=0,n1=0,n2=0,n3=0,n4=0;        cout<< "input string:";        Gets (str);             while (str[i]!= ') {if (str[i]>= ' 0 ' &&str[i]<= ' 9 ') n1++;              else if (str[i]>= ' a ' &&str[i]<= ' z ') n2++;                  else if (str[i]>= ' A ' &&str[i]<= ' Z ') n3++;                  else n4++;        i++; } cout<< "The number of numbers is:" <<n1<<endl<< "where the number of lowercase letters is:" <<n2<<endl<< "where the number of capital letters is:"      <<n3<<endl<< "Number of other characters:" <<n4<<endl;    return 0; }

Ii. Results of operation



Third, experience

Think the array is a bit difficult to understand, the actual operation is difficult, but the teacher began to give the template, referring to the template to consider the rational use of the loop structure or completed the code.

Iv. Summary of Knowledge points

The use of arrays and circular structure is inseparable, to learn the rational use of circular structure, in the assignment should also be properly considered.


C + + Experiment 5--The number of letters (large/lowercase), number of numbers, and number of other characters in the output string.

Related Article

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.