Software Engineering Second Job

Source: Internet
Author: User

Title: Please write a "software" that can automatically generate primary arithmetic topics. Allow the program to accept the user to enter the answer, and determine the right and wrong. Finally, the total number of pairs/errors is given.

-Demand Analysis

For the needs of primary school students, design a self-test system, which requires the system can randomly generate two numbers and operators, when the input answer is, can automatically determine the right and wrong, and give hints, exit the system, statistical right, wrong number of questions.

-Design

Using C language to realize the addition, subtraction, multiplication and arithmetic of students ' self-test system

-Code implementation

1#include <stdio.h>2#include <time.h>3#include <stdlib.h>4 voidMain () {5  inta,b,c,d;6  intright=0, wrong=0;7   while(1){8 Srand (Time (NULL)); 9D=a=rand ()% -; TenB= (rand ()%a+a)% -; One   if(a%4==1&&a<b) Ac=a,a=b,b=C; -   if(b==0&&a%4==3) B=rand ()%Ten+1; -   if(a%4==3&&a%b!=0) the   { -Srand (Time (0));  -A=b* (rand ()%a); -   }   +   Switch(d%4) -   { +    Case 0:p rintf ("%d +%d =", A, b); A     Break; at    Case 1:p rintf ("%d-%d =", A, b); -     Break; -    Case 2:p rintf ("%dx%d =", A, b); -     Break; -    Case 3:p rintf ("%d÷%d =", A, b); -     Break; in   }   -scanf"%d",&c); to   Switch(d%4) +   { -    Case 0: the    if(c==a+b) *    { $printf"answer right \ n");Panax Notoginsengright++; -    } the    Else +    { Aprintf"answer error \ n"); thewrong++; +    } -     Break; $    Case 1: $    if(c==a-b) -    { -printf"answer right \ n"); theright++; -    }Wuyi    Else the    { -printf"answer error \ n"); Wuwrong++; -    } About     Break; $    Case 2: -    if(c==a*b) -    { -printf"answer right \ n"); Aright++; +    } the    Else -    { $printf"answer error \ n"); thewrong++; the    } the     Break; the    Case 3: -    if(c==a/b) in    { theprintf"answer right \ n"); theright++; About    } the    Else  the    { theprintf"answer error \ n"); +wrong++; -    } the     Break;Bayi   } theprintf"Press any key to continue, 0 exit! \ n"); the fflush (stdin); -   if(GetChar () = ='0') -     Break;  the  } theprintf"you got the%d question right, you answered the wrong%d question \ n", Right,wrong); the}

-Test

Steps

Time-consuming Percent (%)
Demand analysis

5

26.3
Design 4 21st
Code implementation 8 42.1
Test 1 5.3
Analysis and summary 1 5.3

Post-mortem analysis and summary

I think writing programs is a big problem, mainly in the programming language is not familiar with, and do not know how to write.

Software Engineering Second Job

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.