Introduction to Software engineering first week comprehensive test

Source: Internet
Author: User

The procedure of randomly producing 30 pupils arithmetic. It is encoded here in C + +.

Design ideas: Comprehensive student examples and Baidu. The function that generates the random number first is rand (), with a for loop of 30 times to 30 questions. The arithmetic is randomly defined by case. Only ask for a question, so direct output random number and random operation symbol. Because primary arithmetic do not involve negative numbers, the comparison size ensures that the subtraction does not produce negative numbers.

//randomly generate 30 primary arithmetic#include<iostream>#include <cmath>
using namespacestd;voidMain () {intA,b,i,r,y; for(i=0;i< -; i++) {a=rand ()% -; b=rand ()% -; Y=rand ()%4; Switch(y) { Case 0: cout<<" "<<a<<"+"<<b<<"="<<Endl; Break; Case 1: if(a<b) {R=A; A=b; b=R; }//Avoid negative numberscout<<" "<<a<<"-"<<b<<"="<<Endl; Break; Case 2: cout<<" "<<a<<"*"<<b<<"="<<Endl; Break; Case 3: cout<<" "<<a<<"/"<<b<<"="<<Endl; Break; } }}

Test results:


Post-Program sense: Did not write this procedure in the specified time, first of all because of poor design thinking, not a good idea and reflective ability to start the topic. I belong to the teacher said the poor programming ability, the main reason is that the programming thinking is not agile. The mind does not build a good programming thinking system, the brain is not enough, the hands are not enough. The next is the usual programming relies on Baidu, always first through the construction of Baidu General thinking and then change. When faced with a blank, in addition to the basic structure of the program can be thought of, there is no better idea. For their own recognition of deficiencies and shortcomings, will be squeezed through spare time.

Introduction to Software engineering first week comprehensive test

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.