Read the Test applet

Source: Internet
Author: User

First here to talk about the personal experience of the last two months of the program, to the medium-term enthusiasm for a little bit of cooling, especially after the complexity and difficulty of the content of the increase, the individual also has lazy time, a lot of weeks have no progress, very annoying, But here's to the same programmer as me. A beginner says my current chicken blood motto: No end to effort, success is not too far. Come on, everybody!

OK, here is a brief introduction of my small program, is a time for you to read the management and testing procedures, quite simple to use the vector and set the mix, to achieve is a number of loops and judgment statements, the following nonsense does not say the attached code and the results of the operation:

#include "stdafx.h" #include <iostream> #include <string> #include <vector> #include <set># Include <cstdlib> #include <ctime>using namespace Std;int main () {//Here first create a container to deposit the title you want to read in string BookName; vector<string>ivec;cout<< "What books do you want to read this month:" <<endl;while (cin>>bookname) Ivec.push_back ( BookName); size_t num=ivec.size ();//Create a set here, and save the book in set<string>mark;string Choice,bname;bool onemonth=false ; Srand ((unsigned) time (NULL));//Get a random number rand () Cin.clear () in accordance with the system times (!onemonth) && (!ivec.empty ()) { Cin.clear ();cout<< "Do you want to read now?" y/n "<<endl;cin>>choice;if (choice[0]== ' Y ' | | choice[0]== ' Y ') {int i=rand ()%ivec.size ();//This is to set the vector's subscript to random number, let the system randomly recommend a book to us in the vector bname=ivec[i];cout<< "We recommend this book for you to read:" <<endl;cout<<bname<<endl;mark.insert (bname); Ivec.erase (Ivec.begin () +i); cout << "After a week, have you finished reading this book?" y/n "<<endl;cin>>choice;if (choice[0]== ' N ' | | choice[0]== ' N ') {mark.erase (bookname);//This time the book has not been read from the reading of the deleted Ivec.push_bACK (bookname);//deposit into the unread}}cout<< "one months? y/n "<<endl;cin>>choice;if (choice[0]== ' Y ' | | choice[0]== ' y ') onemonth=true;} if (onemonth) {if (!mark.empty ()) {cout<< "This month you read these books:" <<endl;for (Set<string>::iterator iter= Mark.begin (); Iter!=mark.end (); iter++) {cout<<*iter<< "";}} Cout<<endl;if (!ivec.empty ()) {cout<< "This month you still have these books unread:" <<endl;for (Vector<string>::iterator it =ivec.begin (); It!=ivec.end ();) {cout<<*it<< ""; ++it;}} Cout<<endl;if (Mark.size () ==num) cout<< "to force! Read all the books, really genius! ";} System ("pause"); return 0;}


Like me the vast number of beginners, adhere to!

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Read the Test applet

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.