These two days do a lot of random function usage (below is a quiz experiment).

Source: Internet
Author: User

#include"stdio.h"#include"stdlib.h"#include"time.h"Main () {inta,b,c,x,d,f=0, g=0;        Srand ((unsigned) time (NULL)); A=rand ()% ++1; b=rand ()% ++1; printf ("Please select the addition operation of the title \n1.1-1000 the subtraction operation of the \n2.1-1000 \n3.1-1000 the multiplication operation \n4.1-1000 the division operation \n5. Exit answer \ n"); scanf ("%d",&x); System ("CLS");  while(g<=Ten)    {             if(x==1) {D=a+b; printf ("%d+%d=", A, b); }        Else if(x==2) {D=a-b; printf ("%d-%d=", A, b); }        Else if(x==3) {D=a*b; printf ("%d*%d=", A, b); }        Else if(x==4) {D=a/b; printf ("%d/%d=", A, b); }        Else{printf ("Press any key to exit! "); Break; } scanf ("%d",&c); if(c==d) {f=f+Ten; printf ("Congratulations, that's correct! Your score is%d minutes \ n", F); }            Else{f=f-Ten; printf ("Sorry, the answer is wrong! Your score is%d minutes \ n", F); } g++; }}

These two days do a lot of random function usage (below is a quiz experiment).

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.