随机生成数
Posted minttremor
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了随机生成数相关的知识,希望对你有一定的参考价值。
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
void main()
{
time_t ts;
srand((unsigned int)time(&ts));
int a[10];
for (int i = 0; i < 10; i++)
{
a[10] = rand() % 100;
printf("
%d,%x",a[10],&a[10]);
}
int all = 0;
double total = 0.0;
for (int i = 0; i < 10; i++)
{
all += a[10];
}
total = all;
total /= 10;
printf("
和=%d,平均值=%f", all, total);
getchar();
}
以上是关于随机生成数的主要内容,如果未能解决你的问题,请参考以下文章