zoukankan      html  css  js  c++  java
  • 时间作为种子(随机数的产生)

    #include <stdio.h>

     

    #include <stdlib.h>

     

    #include <time.h>

     
     

    int main(void)

     

    {

     

      int i = 0;

     

     srand((unsigned)time(NULL)); //本地时间为种子

     

      while(i<30)

     

      {

     

        int a = rand()%100; //产生随机数

     

        int b = rand()%100;

     

        int j;

     

          j = rand()%4; //产生随机符号0到3分别代表四则运算

     

        printf("%d", a);

     

        switch(j)

     

        {

     

          case 0:

     

            printf("+");

     

            break;

     

          case 1:

     

            printf("-");

     

            break;

     

          case 2:

     

            printf("*");

     

            break;

     

          case 3:

     

            printf("/");

     

            break;

     
     

        }

     
     

        printf("%d", b);

     

        printf(" = ");

     

        i++;

     

      }

     
     

      return 0;

     

    }    

    梦里不知身是客,一晌贪欢。
  • 相关阅读:
    koller——PGM 基础
    java 类 多态
    java 基础知识
    相关性检验和独立性检验
    IDEA远程连接Hadoop
    sklearn pipeline
    java static
    sklearn learn preprocessing
    数据预处理 简介
    RATE-MAX alpha冲刺第八天
  • 原文地址:https://www.cnblogs.com/dccmmtop/p/4840419.html
Copyright © 2011-2022 走看看