I. Integral type array: int numsarray[]
Floating-point array: float scorearray[]
Array of strings: numsarray[]
When defining an array, you must be able to determine the number of elements in the array.
Two. Define an array with 5 elements, the default value of each element = 0;
1?? int numsarray[5];(5*4=20 memory space)
There are 5 elements in the array, each of which is an integral type.
2?? int numsarray[]={1,2,3,4};(4*4=16 memory space)
Defines an array with four elements, followed by 1,2,3,4
3?? int numsarray[5]={1,2};(5*4=20 memory space)
Defines an array that has 5 elements, the first is 1, the second bit 2, and the default is 0.
Three. Accessing array functions
The index value starts at 0, for example:
The int numsarray[0]//corresponds to the index value starting with 0, the first element within the array.
Array: Used to store multiple data of the same type
Four. Set the seed of random number in C language
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main () {
Srand ((unsigned int) time (NULL));
for (int i = 0;i<5;i++) {
printf ("%d", rand ()%9+1);
}
printf ("\ n");
return 0;
}
Five. Bubble sort
int temp;
for (int i = 0;i <4;i + +) {
for (Int J =4-1-1;j >=i; J--) {
if (Array[j] > array[j+1]) {
temp = array[j+1];
ARRAY[J] = array[j+1];
ARRAY[J+1] = temp;
}
}
}
12-08 about bubbling sort and array