1#include <stdio.h>2#include <stdlib.h>3 intMain ()4 {5 6 voidBubbleint*a,intn);7 8 inti,n,a[ -];9 Tenprintf"Please enter the number of elements in the array (no more than 100):"); Onescanf"%d",&n); A - for(;n<1|| N> -;){ -printf"the number of elements is out of range, please reenter:"); thescanf"%d",&N); -}printf ("\ n"); - - for(i=0; i<n;i++){ +printf"Please enter the element a[%d]:", i); -scanf"%d",&a[i]); +}printf ("\ n"); A atprintf"you have entered the following elements: \ n"); - for(i=0; i<n;i++){ -printf"%d", A[i]); -}printf ("\ n"); - - Bubble (a,n); in -printf"increment arrangement to: \ n"); to for(i=0; i<n;i++){ +printf"%d", A[i]); -}printf ("\ n"); the *System"Pause"); $ return 0;Panax Notoginseng } - the voidBubbleint*a,intN) + { A inti; the if(n==1){ + return; - } $ for(i=0; i<n-1; i++){ $ if(a[i]>a[i+1]){ - intt=a[i];a[i]=a[i+1];a[i+1]=T; - } the } -Bubble (a,n-1);Wuyi}View Code
C-language Bubble sort Recursive method