30 arithmetic problems in the second grade

Source: Internet
Author: User

Ideas: (1) generate two random numbers within 1-100 and randomly arithmetic;

(2) The loop is carried out 30 times, producing 30 questions;

(3) in the second grade, did not learn the score and negative, the meiosis is less than or equal to be meiosis.

SOURCE program code:

#include "stdafx.h"

#include "iostream.h"

#include "Stdlib.h"

#include "math.h"
#include "time.h"

int main (int argc, char* argv[])

{

int A, B;

int m;

Srand ((unsigned) time (NULL));

for (int i=1;i<=30;i++)

{

A=rand ()%100;

B=rand ()%100;

M=rand ()%4;

Switch (m)

{

Case 0:

cout<<i<< "" <<a<< "+" <<b<< "=" <<endl;

Break

Case 1:

if (a>=b)

{

cout<<i<< "" <<a<< "-" <<b<< "=" <<endl;

Break

}

Case 2:

cout<<i<< "" <<a<< "x" <<b<< "=" <<endl;

Break

Case 3:

cout<<i<< "" <<a<< "/" <<b<< "=" <<endl;

Break

}

}

return 0;

}

The results are as follows:

30 arithmetic in second grade

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.