March 6 after-school homework

Source: Internet
Author: User

In fact, the problem in the first time when most will feel simple, easy degree is like a freshman beginner C + + when the usual exercises, so perhaps in estimating their needs to complete the time will be shorter, slowly with the requirements of the topic step-by-step improvement, the completion of their own time will be more and more long, At the back of the need to take into account that the software to bear the many people at the same time, because most of the students have not been exposed to this knowledge, will feel that they can not complete such a program.

I think a simple or complex program in the completion of the process will always encounter some unexpected problems, it is not the need to take a look at the needs of all the possible difficulties, we need to consider these emergencies, we need to write a program before you leave enough room to think about how to plan the program, Consider all possible problems (for example, although the program is simple, but most students forget the use of simple random number generation functions), even if they are not comprehensive. But also should be in the program to complete the estimated time to leave a certain amount of spare, neither too long, can not blindly confidently estimate the time is too short, so that we can in a reasonable time range and the right arrangements for the deployment of customer needs to gradually improve to a stable software to use.

-----------------------------------------------I'm a split line----------------------------------------------------

These are just my own some shallow views, may be very one-sided, if there is no place to look at the teacher criticism.

About this program, to generate a true score can be generated by generating two random numbers, one as a numerator, the other as the denominator, but also to distinguish two random numbers from the size, to avoid generating false scores. About randomly generated arithmetic, you can use a random number between 1~4 to correspond to the subtraction of arithmetic, and all the random numbers in the program have been controlled in the closed interval of 0~100.

/*======================================================================
# Author:zhangyapeng
# e-mail: [Email protected]
# Last modified:2015-03-08 10:42
# Filename:Demo.cpp
# Description:
======================================================================*
1# include <iostream>2 using namespacestd;3 4 //exercises containing true scores5 voidDisplay1 ()6 {7 intK,a,b,c,d;//k determine what kind of arithmetic randomly generated8 //A and B generate the first true score if it contains multiples of 5, an integer is generated9 //C and D ibid .Ten for(intI=0;i<4; i++) One { AK = rand ()%4+1; -A = rand ()%101;//generate a random number between 0~100 -b = rand ()%101; thec = rand ()%101; -d = rand ()%101; - if(A&GT;B)//set A to a smaller number B as a larger number - { +A = a ^b; -b = a ^b; +A = a ^b; A } at if(c>d)//set C to a smaller number d for a larger number - { -c = C ^D; -D = c ^D; -c = C ^D; - } in if((a%5==0|| b%5==0) && (a+b< -)) -cout<<a+b; to Else +cout<<"("<<a<<"/"<<b<<")"; - if(k==1) thecout<<" + "; * Else if(k==2) $cout<<" - ";Panax Notoginseng Else if(k==3) -cout<<" * "; the Else +cout<<" / "; A if((c%5==0|| d%5==0) && (c+d< -)) thecout<<c+d<<" = "<<Endl; + Else -cout<<"("<<c<<"/"<<d<<") = "<<Endl; $ } $ } - - //exercises with no real scores the voidDisplay2 () - {Wuyi intk,a,b; the for(intI=0;i<4; i++) - { WuK = rand ()%4+1;//generate a random number between 1~4 -A = rand ()%101;//generate exercises between 0~100 Aboutb = rand ()%101; $ if(k==1) -cout<<a<<" + "<<b<<" = "<<Endl; - Else if(k==2) -cout<<a<<" - "<<b<<" = "<<Endl; A Else if(k==3) +cout<<a<<" * "<<b<<" = "<<Endl; the Else -cout<<a<<" / "<<b<<" = "<<Endl; $ } the } the the //test function the intMain () - { in Charch; the intN; thecout<<"How many sets of exercises do you want to generate? "; AboutCin>>N; thecout<<"do you want to generate exercises with true scores? y/n:"; theCin>>ch; the if(ch=='Y'|| ch=='y') + { - for(intI=0; i<n;i++) the {Bayicout<<"Section"<<i+1<<"Set of questions"<<Endl; thecout<<"------------------------"<<Endl; the Display1 (); -cout<<"------------------------"<<Endl; - } the } the Else if(ch=='N'|| ch=='N') the { the for(intI=0; i<n;i++) - { thecout<<"Section"<<i+1<<"Set of questions"<<Endl; thecout<<"------------------------"<<Endl; the Display2 ();94cout<<"------------------------"<<Endl; the } the } the Else98 { Aboutcout<<"Data error!"<<Endl; - }101 return 0;102}

March 6 after-school homework

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.