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<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<5;j++ ) printf("...
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=0;i<n;i++ ) { b[i]=a[0][i]; for ( j=1;j<n;j++ ) if (...
else { int k; for(k =2 ;k
比如a[5]=b[5](主函数第二个for循环处);不要把数组整个的作为参数返回,要操作数组直接把数组定义为全局的就可以了,还有关于退进缩格的习惯,你这样谁看得懂你的程序?其他没有仔细认真看(实在是毫无细看的动力,格式太差和注释也没有),自己多总结吧 ...
int main(int argc,char *argv[]){ int **p,*q,i,j,M,N;printf("Enter M & N(int M,N>0)...\n");if(scanf("%d%d",&M,&N)==2 && M>0 && N>0){ q=(int *)malloc(sizeof(int)*M*N);//申请M*N个int空间 if(q && (p=(int **)malloc(sizeof(int *)*M)))...
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]...