C # programming: given a positive integer, the number of digits is obtained and output in reverse order,
A simple program of C language Bubble Sorting
Main (){Int I, j, temp;Int a [10];For (I = 0; I Scanf ("% d,", a [I]);For (j = 0; j {For (I = 0; I If (a [I]> a [I + 1]){Temp = a [I];A [I] = a [I + 1];A [I + 1] = temp ;}}For (I = 1; I Printf ("% 5d,", a [I]);Printf ("\ n ");}--------------Bubble Algorith
DescriptionIn this problem, you has to analyze a particular sorting algorithm. The algorithm processes a sequence of n distinct integers by swapping, adjacent sequence elements until the sequence is Sorted in ascending order. For the input sequence
9 1 0 5 4,
Ultra-quicksort produces the output
0 1 4 5 9.
Your task is to determine what many swap operations Ultra-quicksort needs to perform in order to sort a given input sequenc E.InputThe input contains several test cases.
Label: style blog color Io SP Div on Log Code
Reverse digits of an integer.
Example1: x = 123, return 321Example2: x =-123, return-321
Local attention to positive and negative numbers is critical, and the Implementation part may not be optimal, according to your own ideas:
Set ret = 1; perform the remainder mod on X each time, and then ret = RET * 10 + MOD; (First let ret = mod), and finally return ret
The Code is as follows:
1 public class Solution
Topic Link: Click to open the linkTest Instructions Description: Given an array of length 100000, each element in the range of 1~100000, and not the same, the exchange of any two of them will cost the sum of two numbers. Q How does swapping make arrays orderly and cost the least?Problem Solving Ideas:1, obviously we know, to make an array ordered at least the number of exchanges (that is, the number of time
Topic Link: Click to open the linkTest instructions Descriptive narrative: given an array of length 100000, each element in the range of 1~100000, and not the same, the exchange of random two will cost the sum of two numbers.Ask how the exchange makes the array orderly. The cost is minimal?Problem Solving Ideas:1, obviously we know, to make an array ordered at least the number of exchanges (that is, the number
Xiaoming, get out of here? Time limit:2000/1000ms (java/others) problem Description:Teacher: "Xiao Ming, write a sorting algorithm"; Xiaoming: void mysort (int a[],int N)//n number of elements of array a { int i,j; for (j=0;jInput:Input contains multiple sets of data (EOF), the first row of each group of data is an integer n (1Output:For each set of data, output the number of exchanges of the xiaoming
Links: Poj 2299Test Instructions : gives a sequence of length n, which can only exchange two adjacent elements at a time.Ask at least a few times to make the sequence an ascending sequence Analysis : Bubble sort can only swap adjacent two elements at a time. That is to askuse bubble sort to make it the number of interchanges of an ascending sequence, every time I exchange a record.However, this data is larger, the bubble sort efficiency is low, will t
A few days ago, I figured out how to use the merge sort method to calculate the number of reverse orders. I found a question about the number of reverse orders. I paid 2299 + MS for the problem...
Ultra-QuickSort
Time limit:7000 Ms
Memory limit:65536 K
Total submissions:19686
Accepted:69
Requirements:m is defined as a property of the class, the constructor must be defined as m assignment, and when m is greater than 99999 , the output error message " the number is too large"and is no longer executed. Public classT {Private intm; PublicTintm) {Super(); This. m =m; } Public intGetm () {returnm; } Public voidSetm (intm) { This. m =m; } Public voidM () {if(m>99999) {System.out.println ("The
For details about Merge Sorting, see "Introduction to algorithms"-Divide and conquer law. In the following example, we use the merge method to calculate the number of reverse orders for the 2299 questions in poj:
/** The question indicates the number of exchanges that require Bubble sorting. Algorithm used: sort by merge to calculate the
Test instructions: give you a sequence, and a standard sequence line, to find the intersection of points.The best way to do this is to find the number of reverse order, and use array array to optimize it.Do eight digital time, ask for reverse number search how to beg, but the practice forgot ... So on the spot how to a
Title Link: https://www.51nod.com/onlineJudge/questionCode.html#!problemId=1107Idea: In fact, is the upgrade version of the reverse number, X coordinate as a position, y coordinate as a value Val, but there may be equal number, a little modification can be.#include 51nod 1107 (tree-like array, reverse order
This is also the reverse order number, but the topic description is a bit strange =! Given is the hook ID, not a one-to-one relationship, so you need to map it. You prefer to use merge to find the reverse order number.
#define N 1010int a[N],b[N];int tmp[N];int sum;void merge_sort(int l,int mid,int r){ int i = l,j
Problem description
There is a concept in Linear Algebra: There is a series, such as 21543,
The first digit of 1 is larger than that of 4, and the first digit of 4 is larger than that of 1,
The first two numbers in 3 are larger than that in 3. The total number is 1 + 1 + 2 = 4.
So the reverse order of 21543 is 4.
InputMultiple groups of test data. The first line is n (1
OutputCalculate the
p2804-Mysterious number Title description (Simplified version)There are n numbers, and in this n number, how many consecutive numbers are the averages greater than a given number of M?Note: This number can be very large, please output this number to 92084931 modulo results.I
Package Lianxi; Import Java. util .* ; Public Class Nixudayin { Public Static Void Main (string [] ARGs) {system. Out. println ( "Enter a positive integer of no more than five digits" ); Mongoshu = New Struct (system. In); string =SHU. Next (); system. Out. println ( "The input is" + A. Length () + "digits" ); System. Out. println ( "Print in reverse order :" ); For ( Int I = A. Length ()-1; I> = 0; I -- ) {System. Out. Print (A. substri
Returns a reverse_prime, which is a 7-digit number and a prime number First, find all such numbers.Two operationsQ k: deletes the number K.Http://uva.onlinejudge.org/index.php? Option = com_onlinejudge Itemid = 8 page = show_problem problem = 2657
First, all the reverse_prime values are pre-processed. In this case, all the prime numbers of Then we will
I used a line segment tree to calculate the number of reverse orders. This time I want to use a tree array to try it. The sad reminder is that I want to understand it for a long time .... I don't know enough about tree arrays. Tangle .... Question:
Minimum inversion number
Time Limit: 2000/1000 MS (Java/others) memory limit: 65536/32768 K (Java/Others)Total submi
passing is the time when the two spaceships are at the same position.
Sample Input
40 22 13 86 3
Sample output
23 41 2
Question: The starting point (not overlapped) and speed of a spacecraft fly in the same direction. Question 1: The total number of times each spacecraft is exceeded (Model 1000000). Question 2: output The first 10000 superships, sorted by time, and if the time is the same, sorted by the input order of the ships that surpass other sh
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.