exr10_15.c
来自「Software Development in C: A Practical A」· C语言 代码 · 共 60 行
C
60 行
//-----------------------------------------------
// Include Files
//-----------------------------------------------
#include <stdio.h>
#include <stdlib.h>
//End Include Files------------------------------
//-----------------------------------------------
// Constants
//-----------------------------------------------
const int ARRAY_LENGTH = 100;
//End Constants----------------------------------
int main()
{
int i, j, integerArray[ARRAY_LENGTH];
int temp;
// Fill the array with random integers.
// For each array element...
for (i=0;i<ARRAY_LENGTH;i++)
{
/* Generate a random integer and store
it in the array. */
integerArray[i]=rand();
}
printf("\nThe array in random order...\n");
// For each array element...
// Print the array element.
// For each array element...
// For each element less than the current element
for (j=0;j<i;j++)
{
if (integerArray[i]<integerArray[j])
{
/* Swap the values in
integerArray[i] and
integerArray[j]. */
}
}
}
printf("\nThe array in sorted order...\n");
// For each array element...
// Print the array element.
return (0);
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?