The first section of the classroom summary

Source: Internet
Author: User

Homework in class is to write a arithmetic of 30 100 or less, which requires integers and arithmetic symbols to be randomly generated. Get the title first think about using the RAND function to produce integers in the output topic.

Program code:

#include <iostream>
using namespace Std;
void Main ()
{
int a,b,i,c;
for (i=0;i<30;i++)
{
A=rand ()%100+1;
B=rand ()%100+1;
C=rand ()%4+1;

if (c==1) cout<< "(" <<i+1<< ")" <<a<< "+" <<b<< "=" <<endl;
if (c==2) cout<< "(" <<i+1<< ")" <<a<< "-" <<b<< "=" <<endl;
if (c==3) cout<< "(" <<i+1<< ")" <<a<< "*" <<b<< "=" <<endl;
if (c==4) cout<< "(" <<i+1<< ")" <<a<< "/" <<b<< "=" <<endl;

}
}

Operation Result:

(1) 42*68=
(2) 1+70=
(3) 79*59=
(4) 65-6 =
(5) 82-28 =
(6) 92*96=
(7) 28/37=
(8) 5-3 =
(9) 93-83 =
(10) 17/19=
(11) 48/27=
(12) 39+70=
(13) 68/100=
(14) 95/4=
(15) 23-34 =
(16) 65/42=
(17) 54/69=
(18) 45-63 =
(19) 38/60=
(20) 42*30=
(21) 17*36=
(22) 43*89=
(23) 41+43=
(24) 49-47 =
(25) 91*30=
(26) 51-7 =
(27) 94-49 =
(28) 24*85=
(29) 57*41=
(30) 77+32=
Please press any key to continue ...

Cause: In class, there is no thought that the method of randomly generating operational symbols does not fulfill the requirement successfully.

The first section of the classroom summary

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.