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.