Nothing Special   »   [go: up one dir, main page]

C ++ array - direct sequencing

tags: I am a small white C ++

// Sort from left to right
#include<iostream>
#include<cstdio>
using namespace std;
int a[10]={2,52,45,63,98,25,12,36,5,47};
int main()
{
	for(int i=0;i<10;i++){
		for(int j=i;j<10;j++){
			int b;
			if(a[j]<a[i]){
				b=a[j];
				a[j]=a[i];
				a[i]=b;
			}
			/ * Discover than a number of small numbers of A [i] * /
		}
	}
	for(int n=0;n<10;n++){
		cout<<a[n]<<endl;
	}
	return 0;
}
 

Output:

2
5
12
25
36
45
47
52
63
98

Think carefully, in fact, this is not the topicASC II code sortUpgraded version?

Intelligent Recommendation

Sort: bubbling, simple sequencing, direct insertion, Hill sort, stack sort, fast sorting introduction and C language implementation

Sort (Reference Battle Data Chapter 9, Multiple Sort Nothing, the rapid sorted optimization section did not see) Related concepts: 1.Sorting: Depending on whether the recording to be sorted in the sor...

C # uses a bubbling method to sequencing 10 integers in the array in small to large.

1. The requirements of the topic are as follows: 10 intenses in arrays in the foaming method are sorted from small to large. // The array itself is a reference type. 2. Come on, the code is as follows...

Leet Code 559. The maximum depth of the n fork tree (improved, dynamically created array + sequencing or direct assignment recursive comparison)

Given a n fork tree to find its maximum depth. The maximum depth refers to the total number of nodes on the maximum path from the root node to the maximum leaf node. The n-fork tree input is sequencet...

GO array and string sequencing

First, the minimum (large) element is found in the unsorted sequence, stored in the start position of the sort sequence The minimum (large) element is continued from the remaining unsained element, an...

Sequencing the array into a Tree structure

Foreword: In daily development, some tiled data will often be serialized. Below is a personal summary, a way to write, I hope that if you have a problem, problems or better solutions, I hope everyone ...

More Recommendation

One of the eight sorting algorithms: Direct sequencing

Direct sequencing Generally, insertion sort are implemented using in-place on the array. The algorithm is described as follows: From the beginning of the first element, the element can be considered t...

[Algorithm] Simple sequencing sorting and direct insertion

          Simply selecting the sorting and direct insertion sorting is the simplest two algorithms in the sorting algorithm, making a comparison more easily understood.  ...

Direct sequencing algorithm time / space complexity

Thought: Each time you find the minimum coordinates, then exchange your location with the front. Code:...

DNA sequencing (C ++)

Beginning with that sort sorting, have been wa, later wrote out a selection sort, AC a...

Copyright  DMCA © 2018-2025 - All Rights Reserved - www.programmersought.com  User Notice

Top