C程序:include <stdio.h> include include <stdlib.h> void main(void){ int i;int arr[10];srand(time(NULL));for(i=0; i<10; i++)arr[i] = rand() % 10;for(i=0; i<10; i++)printf("%4d", arr[i]);printf("\n");} ...
include "stdio.h"#include <stdlib.h>#include "time.h"int main(int argc,char *argv[]){int a[10],i;srand((unsigned)time(NULL));for(i=0;i<10;a[i++]=rand()%46+25);for(i=0;i<10;printf("%3d",a[i++]));//打出来看看……printf("\n"); return 0;}运行样例:
include "stdio.h"int main(){ int a[10],i; srand((unsigned)time(NULL)); for(i=0;i<10;i++) a[i]=rand()%100; for(i=0;i<10;i++) printf("%d,",a[i]);}
include <stdio.h>#include <stdlib.h>#include int main(){ int n, **a, *b; int i,j; srand(time(NULL)); scanf("%d",&n); if(n<=0) { printf("input error\n"); return -1; } b=(int *)malloc(sizeof(int)*n); a=(int **)mallo...
include<stdio.h> include<stdlib.h>#includevoid main(){ int a[5][5],i,j,k,m,n; srand((unsigned int)time(NULL)); for ( i=0;i<5;i++ ) for ( j=0;j<5;j++ ) a[i][j]=rand()%21+30; for ( i=0;i<5;i++,printf("\n") ) for ( j=0;j<...
include<stdio.h>#include<stdlib.h>#include#define N 256void main() { int n,i,j,a[N][N],b[N]; srand((unsigned int)time(NULL)); scanf("%d",&n); if ( n>N ) n=N; for ( i=0;i<n;i++ ) for ( j=0;j<n;j++ ) a[i][j]=rand()%100; for ( i=...
else { int k; for(k =2 ;k
比如a[5]=b[5](主函数第二个for循环处);不要把数组整个的作为参数返回,要操作数组直接把数组定义为全局的就可以了,还有关于退进缩格的习惯,你这样谁看得懂你的程序?其他没有仔细认真看(实在是毫无细看的动力,格式太差和注释也没有),自己多总结吧 ...
for(i=0;i<M;p[i]=q+N*i++);//组织成二维数组 srand((unsigned)time(NULL));//随机种子 for(i=0;i<M;i++){ for(j=0;j<N;printf("%4d",p[i][j++]=rand()%900+100));putchar('\n');} free(p);free(q);} else{ printf("Application memory failure, exit...\n")...
init_array(int *p,int n){ int i; srand((unsigned)time(NULL)); for(i=0;i<n;p[i++]=rand()%90+10);}void mysort(int *p,int n){ int i,j,k; for(i=0;i<n;i++){ for(k=i,j=k+1;j<n;j++) if(p[k]...