C语言打乱一组数字顺序
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<time.h>
int main()
{
int a[] = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16};
int n=16;
int i,j,T=1000,tmp;
srand(unsigned(time(NULL)));
while(T--)
{
i=rand()%n;
j=rand()%n;
tmp=a[i];
a[i]=a[j];
a[j]=tmp;
}
for(i=0;i<n;i++)
printf("%d ",a[i]);
puts("");
return 0;
}本文出自 “阿凡达” 博客,请务必保留此出处http://shamrock.blog.51cto.com/2079212/1429940
积跬步以致千里,积小流以成江海。
2016年5月之前的博文发布于51cto,链接地址:shamrock.blog.51cto.com
2016年5月之后博文发布与cnblogs上。
Github地址 https://github.com/umgsai
Keep moving~!!!
2016年5月之前的博文发布于51cto,链接地址:shamrock.blog.51cto.com
2016年5月之后博文发布与cnblogs上。
Github地址 https://github.com/umgsai
Keep moving~!!!

浙公网安备 33010602011771号