C Language Clear screen, wait, random function

Source: Internet
Author: User
Tags clear screen

Clear Screen function

#include <conio.h>System ("CLS"); or system (CLS);wait function#include <windows.h>Sleep (5000);//wait 5 seconds, sleep () in milliseconds Random number function#include <time.h>

#include <stdlib.h> (description of NULL)

Srand (Time (NULL)); (If the order of the random numbers generated is the same)
RAND ()%100+1;//generates 1-100 of random numbers
(General Srand and Rand are used in conjunction with the generation of pseudo-random number sequences.) The RAND function requires a system-supplied seed to generate a sequence of pseudo-random numbers before generating a random number.
Rand produces a series of random numbers based on the value of this seed. If the seed provided by the system does not change, the sequence of pseudo-random numbers generated by each call to the RAND function is the same.
Srand (unsigned seed) alters the seed value provided by the system through the parameter seed, which allows the sequence of pseudo-random numbers generated by each call to the RAND function to be different, thus achieving a true "random" meaning.
System time can often be used to change the system's seed value, which is srand, which can provide different seed values for the RAND function, resulting in a different sequence of random numbers.

C Language Clear screen, wait, random function

Related Article

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.