-
The amount of data is so small, you don't need to arrange it quickly, it's a waste, just a two-fold for loop can be done, the procedure is as follows:
#include
const int n=10;
int a[n],i,j;
int main()
for (i=0;ia[j])
a[i]+=a[j];
a[j]=a[i]-a[j];
a[i]-=a[j];
for (i=0;iprintf("%d ",a[i]);
printf("");
return 0;
-
If you don't speak any language, how can others help you?
-
It's just what language to write a program in? I'm dizzy.
-
Bubbling method
define num n * n * number of data * void main().
int a[num],i,j,t;
scanf("%d",&a[i]);*Enter data, separated by tab key *for(i=0; iprocedure sort(l,r: longint);
var i,j,x,y: longint;
begini:=l; j:=r; x:=a[(l+r) div 2];
repeat
while a[i]while xif i<=j then algorithm stability.
Bubbling is the process of putting small elements in front or large elements in the back. A comparison is a comparison of two adjacent elements, and the exchange also takes place between these two elements. So, if the two elements are equal, they will not be swapped again.
If two equal elements are not adjacent, then even if the two are adjacent by the previous pairwise exchange, they will not be swapped at this time, so the order of the same elements does not change, so bubble sorting is a stable sorting algorithm.
-
c Read two parameters.
consolekeyinfo a = ;
consolekeyinfo b = ;
If the value of a is greater than b, ab is output, otherwise baif(>=,"+
else{","+
-
According to the requirements of the problem, we can directly store the data into the array, and then output the array elements in reverse order, without changing the data.
Correct ** as follows:
#include
#define n 2000
int main ()
int i=0;
int n=0,a[n];
scanf("%d",&n);
for(i;iscanf("%d",&a[i]);
for(i=n-1;i>=0;i--)
printf("%d ",a[i]);
return 0;
-
Enter an integer in the first line, which is easy to manipulate, just scanf.
However, if you input n integers on the second line and assign values to an integer array, you can't do it directly, you can only store all the numbers entered in the second line into a string first, and then use a loop to parse the string according to the number entered in the first line, and then assign values to the integer array one by one.
Or press enter for each integer.
The specific process is as Richardbao2000 said: 1, read 10 numbers. >>>More
Find the common divisor like two numbers m and n
r=m%n; >>>More
I'll fix it, friend, I don't want to divide it, hehe.
r=0; c=1;It is to assign an initial value to r and c. >>>More
Just use an array.
var a:array[1..1000]of longint; >>>More
The question you are talking about belongs to permutations and combinations and simple number theory. >>>More