Arithmetic 2--c++

Source: Internet
Author: User

1. Design ideas:

The previous article has been written, not in explanation .....

2. Source code:

#include <iostream.h>
#include <stdlib.h>
#include "time.h"
int main ()
{
int a,b,c,f,j,i,t,num,l,jj,cc,fw;//i,j,t is a count variable, and a, B is the operand.
cout<< "-----------------arithmetic----------------------" <<endl;
cout<<endl;
Srand ((unsigned) time (NULL));//The random number seed is the current computer.
cout<< "************* please fill in the title request: ********************" <<endl;
cout<< "* *" <<endl;
cout<< "* 1. Please enter the number of questions to generate NUM: *" <<endl;//Select the number of topics.
cout<< "* 2. Please enter how to print (Number of columns L, line spacing JJ): *" <<endl;//choose how to print.
cout<< "* 3. Please select if there is no multiplication cc (1 for or 0 for none): *" <<endl;//there is no multiplication method.
cout<< "* 4. Please select the range of the number of FW (FW refers to the largest number in the range): *" <<endl;//the range of the selected number.
cout<< "* 5. Please select the division has an all-in-one number C (1 for have or 0 for none): *" <<endl;//Select Division has no number. "
cout<< "* 6. Please select Plus or minus negative F (1 for either or 0 for none): *" <<endl;//Select Plus or minus with or without negative numbers. "
cout<< "* *" <<endl;
cout<< "*************************************************" <<endl;
cout<< "Please enter number of questions to generate num:" <<endl;
cin>>num;
if (num<0)
{
cout<< "Wrong! Kiss! The number of topics can not be less than 0, please re-lose: ";
cin>>num;
}
cout<< "Please enter printing method (number of columns L):" <<endl;
cin>>l;
if (l<=0)
{
cout<< "Wrong! Kiss! The number of columns cannot be less than or equal to 0, please re-lose: ";
cin>>l;
}
cout<< "Please enter the printing method (line spacing JJ):" <<endl;
cin>>jj;
if (jj<=0)
{
cout<< "Wrong! Kiss! The line spacing cannot be less than or equal to 0, please re-lose: ";
cin>>jj;
}
cout<< "Please select if there is no multiplication cc (1 for either or 0 for none):" <<endl;
cin>>cc;
if (cc!=0&&cc!=1)
{
cout<< "Wrong! Kiss! Please re-lose: ";
cin>>cc;
}
cout<< "Please select the range of the number of FW (FW refers to the largest number in the range):" <<endl;
cin>>fw;
cout<< "Please select the division has an all-in-one number C (1 stands for or 0 for none):" <<endl;
cin>>c;
if (c!=0&&c!=1)
{
cout<< "Wrong! Kiss! Please re-lose: ";
cin>>c;
}
cout<< "Please select plus or minus negative F (1 for either or 0 for none):" <<endl;
cin>>f;
if (f!=0&&f!=1)
{
cout<< "Wrong! Kiss! Please re-lose: ";
cin>>f;
}
cout<<endl;
if (cc==1)
cc=cc+3;
Else
cc=cc+2;
for (j=0;j<num;j++)
{
Generates a random number.
A=rand ()%FW;
B=rand ()%fw+1;//guarantees that the divisor is not 0.
I=rand ()%cc;
Switch (i)
{
Case 0:
cout<<a<< "+" <<b<< "=" << "";
Break
Case 1:
if (f==0&&a<=b)
cout<<b<< "-" <<a<< "=" << "";
Else
cout<<a<< "-" <<b<< "=" << "";
Break
Case 2:
cout<<a<< "*" <<b<< "=" << "";
Break
Case 3:
if (a%b!=0&&c==0)
cout<<a-a%b<< "/" <<b<< "=" << "";
Else
cout<<a<< "/" <<b<< "=" << "";
Break
}
if (J%L==L-1)
{
for (t=0;t<jj;t++)
cout<<endl;
}
}
cout<<endl;
return 0;
}

3. Operation Result:

4, PSP0 level record table

Summary of weekly activity records

Name: Donglongyan Date:2015.3.14

Date / task

Lectures

Programming

Read

Prepare for the exam

Total Day

Sunday

Monday

Tuesday

20

Wednesday

Thursday

75

Friday

30

Saturday

100

Week Summary

225

Stage time and Efficiency week (week of last week activity Table +1): 1

Cumulative time excluding last week

Total

Average

Biggest

Minimum

Cumulative time of previous weeks

Time Record table:

Student: Donglongyan Date:2015.3.14

Teacher: Wang Course:PSP

Date

Start time

End time

Interrupt Time

NET time

Activities

Note

3.10

9:30

9:50

0

20

Classroom Exercises

3.12

16:05

19:20

60

75

Arithmetic

Eat for an hour

3.13

9;20

9:50

0

30

Classroom Exercises

3.14

18:23

20:03

0

100

Arithmetic

Bug log:

Student: Donglongyan

Date:2015.3.14

Teacher: Chien Wang

Programmers:

Date

Number

Type

Introduction phase

Exclusion phase

Repair time

Fixing defects

3.10

1

Write code

Compile

2min

3.12

2

Write code

Perform

30min

Logic error

5. Summary: Less writing procedures, logic error is not easy to solve, from the middle school to the method is to implement a small function to test.

Variable definition, the structure is not clear, at that time clear, after a while forget, feel a bit of comments to remember a good!!!!

Arithmetic 2--c++

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.