Goals and Requirements
- Using development tools
- Using Source Control Tools
Detailed Requirements:
1. Implement a console program, given an English string, to count the occurrences of each of the English words (4 characters above with 4 characters).
Additional requirements: read a text file to count the frequency of the words in the text file.
2. Performance Analysis:
+ Run VS's performance analysis tool for C + + code to identify performance issues and optimize them.
+ Run Profiling Tools for Java programs NetBeans IDE 6.0, identify performance issues and optimize them.
Detailed content
- Development language: C + +
- Development tools: Codeblocks
- Preparatory work:
- Ideas
(1) The user chooses whether to enter an English string or read a text file.
(2) The input string is divided into several English words.
(3) The segmentation of the English words to filter (less than 4 of the length of the non-statistics, uppercase letters converted to lowercase letter, the first letter is non-alphanumeric words do not count,) where the capital letters converted to lowercase letters to facilitate subsequent statistics.
(4) Statistics and output results.
2. Estimated Time
Write + debug + verify =2h around
1#include <iostream>2#include <fstream>3#include <cstring>4#include <cctype>5 using namespacestd;6 7 voidScreenintCHIOCE)//Filter your content8 {9 Charinput[ -][ -],newinput[ -][ -],newopen[ -];Ten Char*Open; One if(chioce==1)//storing and filtering strings in the form of input A { -cout<<"Please enter a string with the ENTER key to end:"; - for(intm=0; input[m]!=' /'; m++)//Store the string as a two-dimensional character array the { - for(intn=0; input[n]!=' /'; n++) - { -Cin>>Input[m][n]; + } - } + for(intm=0; input[m]!=' /'; m++)//converts the uppercase of the input string to lowercase A { at for(intn=0; input[m][n]!=' /'; n++) - { - if(input[m][n]>='A'&&input[m][n]<='Z'&&strlen (Input) >=4)//limit string size to 4 - { - intI=0, j=0; -newinput[i][j]=toupper (input); in } - } to } +STA (newinput,m*n); - } the * Else //storing and filtering strings in the form of input $ {Panax Notoginseng intI=0, N; -cout<<"Please deposit the required text into D:\\open.txt"; theIfstream Open ("D:\\open.txt"); +open=New int[n]; A while(Open>>open[i],strlen (Open) >=4)//a string greater than 4 gives the opportunity to save the { +Newopen[i]=toupper (open);//uppercase converted to lowercase -i++; $ } $ STA (newopen,i); - } - } the - voidStaCharWord[],intWordnum[])//Count The number of occurrences of a wordWuyi { the Charnewword[],newwordnum[]; -cout<<"The number of occurrences of the word count is as follows: \ n"; Wu for(intI=0;; i++) - { About for(intj=0;if(strcmp (Newword[i],word[j])); J + +) $ { -newwordnum[i]++; - } -cout<<newword[i]<<'\ t'<<newwordnum[i]<<Endl; A } + the } - $ the intMain () the { the intChioce; thecout<<"would you like to enter a string of strings or import a text file? (1: string, 2; text file):"; -Cin>>Chioce; in if(chioce==1|| chioce==2)//User Selection the { the Screen (CHIOCE); About } the return 0; the}
- How to solve the import of the original data in two ways?
Both methods of data import are stored in an array for later reading.
2. How can you reduce the complexity of time and space?
Minimize the use of circular statements and the invocation of new space.
There is a more practical practice for the subdivision of the problem, and there is a preliminary feeling and understanding about the user interface experience;
for a program in the space and time of the use of a preliminary simplification exercise; for some of the library has not been exposed to the understanding;
- Source code GitHub Address
Https://github.com/Jennyhyt/My-source-code
Personal items-word frequency statistics