[ThinkingInC ++] 21. Exercises on C (3)

Source: Internet
Author: User

[ThinkingInC ++] 21. Exercises on C (3)

/*** Function: Use the while loop to read words from the standard input (cin) into the string. This is an "infinite" * while loop. You can use the break statement to interrupt (and exit the program ). For the words to be read, use the series if statement * this word "maps" to an integer, and then use this Integer as the selection condition of a switch statement. The word above indicates that it is the end sign of the program. Use a file to output the Test Program * Time: August 15, 2014 08:22:17 * Author: cutter_point */# include
 
  
# Include
  
   
# Include
   
    
# Include
    
     
# Include
     
      
Using namespace std; // design a class, including all functions class operatorText {public: // operatorText () = default; operatorText (string s = ""): s (s) {} // The words in the standard input (cin) are read into the string void inWord (istream & is ); // The meaning of an integer as the selection condition of a switch statement string theMeanOfInt (); // the words to be read are mapped to an integer using a series of if Statements, you can use void wordToInt (); private: // to store the word string s; // to store the corresponding integer int is ;}; // The words in the standard input (cin) are read into the string void operatorText: inWord (istream & is) {// enter a word, save to class cout <"\ n input word:"; string ps; is> ps; this-> s = ps ;} /* use the series of if Statements to read the words. The word "ing" is an integer. void wordToInt (const string s, int & is); */void operatorText :: wordToInt () {if (s = "I" | s = "I") {is = 5 ;} else if (s = "love" | s = "Love" | s = "LOVE") {is = 5 ;} else if (s = "China") {is = 5;} else {is = 1; cout <"\ n word" <
      
        > PanDuan; if (panDuan = 'I') {while (1) {// create a word object operatorText ot ("haha"); ot. inWord (cin); // enter the word ot. wordToInt (); // enter the meaning of the word cout <
       
      
     
    
   
  
 

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.