Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and beauty - Put the student numbers of 30 students in a class in ascending order! ! ! Then I should use a character array to store the student numbers of these students.
Put the student numbers of 30 students in a class in ascending order! ! ! Then I should use a character array to store the student numbers of these students.
If it is 1 1 bit, only strings can be used. There is no difference between int and long in vc. They are all 4 bytes, and the maximum support is 10. In early tc or earlier, int was 2 bytes and long was 4 bytes. At that time, the concept of dragon has been passed down to this day, but there is no such thing.

The idea of comparing the number of strings is as follows. Suppose that the comparison strings A and B are integers.

First, the lengths la and lb are obtained respectively.

If la is greater than lb, directly judge that a is greater than b, and vice versa.

If the length is the same

For loop, loop la times, i=0.

See which is bigger *(a+i) or *(b+i). If the former is bigger and the result A is bigger, then jump out of the loop; If the latter is bigger and the result comes out, then jump out of the loop.

If the sizes are the same, i++ Next cycle

If the loop is not as big as the result after the loop ends.

Let's not talk about sorting methods. With the comparison method, sorting is simple.