define N 15 int main(int argc,char *argv[]){ int a[N],i,j,k;srand((unsigned)time(NULL));for(i=0;i<N;i++)//数组随机赋值 printf("%3d",a[i]=rand()%100);printf("\n\nAfter processing:\n");for(i=0;i<N;i++){ if((a[i]&1)==0)for(j=i+1;j<N;j++)...
include <stdio.h>#include #include <stdlib.h>#define N (10)int main(void){int a[N],i,j,t;srand(time(NULL));for(i=0;i<N;++i)a[i]=rand()%101+100;for(i=0;i<N;++i){for(j=0;j<N-i-1;++j){if(a[j]>a[j+1]){t=a[j];a[j]=a[j+1];a[j+1]=t;...
include <stdlib.h>#include void main(){int i,a[20],n=0;srand(time(NULL));for(i=0;i<20;i++){a[i]=rand()%146+60;printf("%-4d",a[i]);n++;if(n%5==0)printf("\n");}}运行示例:
j,k,t; srand((unsigned int)time(NULL)); int a[100]; for(i=0;i<=99;i++) //产生随机数组1到100 {a[i]=rand() % 100;a[i]++;} { for(i=0;i<99-1;i++) //最小值 { k=i; for(j=i+1;j<99;j++) if(...
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...
void main(){ int i,max,a[10];srand((unsigned)time(NULL));for(i=0;i<=9;i++)a[i]=rand()%100;max=a[0];printf("十个随机数:");for(i=0;i<=9;i++)printf("%d ",a[i]);printf("\n");for(i=1;i<=9;i++)max=a[i]>max?a[i]:max;printf("最大数为:%d\n...
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=...
1---随机数组初始化为:28 95 15 42 43 25 5 10 76 35 2---数组排序后的结果为:5 10 15 25 28 35 42 43 76 95 3---请输入X值,查找是否存在 25 存在第 4 个位置 4---输入X值,插入数组中。35 插入后的数组为 5 10 15 25 28 35 35...
include "stdio.h"include"windows.h"void main(){ int i,A[100];for(i=0;i<100;i++){ A[i] = rand()%90 + 10;printf("%d ", A[i]);} }
这是个固定的随机值,如果要完全随机就要加很多东西,你初学就只要用这一点就行 include <stdio.h>#include <stdlib.h> //包含随机函数rand()定义int main(){ int pOne[10]; //一维数组 int pTwo[10][10]; //二维数组 int Big; //每排最大值临时变量 int i,...