c 语言 完整程序如下:
#include<stdio.h>
#include <stdlib.h>
#include<time.h>
int main()
{
double *x,t;
int i,j,N;
N=100;
srand(time(0));
x = (double *) malloc(sizeof(double) * N);
for (i=0;i< N;i++){
t = ( (double)rand() / ((double)(RAND_MAX)+(double)(1)) );
x[i] = (t * 19)+1.0;
};
for (i=0;i<N-1;i++) for (j=i+1;j<N;j++)
if (x[j]<x[i]){t=x[i];x[i]=x[j];x[j]=t;};
for (i=0;i<N;i++) printf("%lf\n",x[i]);
return 0;
}
温馨提示:内容为网友见解,仅供参考