Write a C console application that implements bubbling sort requiring na ve algorithms to be writte

Updated on technology 2024-03-21
6 answers
  1. Anonymous users2024-02-07

    using system;

    using ;

    using ;

    using ;

    static void main(string args)int a = ;

    for (int i = 0; i < i++)for (int j = i + 1; j < j++)if (a[i] >a[j])

    int b = a[i];

    a[i]=a[j];

    a[j]=b;

    string c = "";

    for (int k = 0; k < k++)c = "",a[k])+c;;;

    Tested by operation No problems.

    Result 12 11 9 8 5 3 2 1 0The specific content is modified by yourself.

  2. Anonymous users2024-02-06

    Here's how the bubble sorting algorithm works:

    1. Compare adjacent elements. If the first one is bigger than the second, swap both of them.

    2. Do the same work for each pair of adjacent elements, starting with the first pair and ending with the last pair. At this point, the final element should be the largest.

    3. Repeat the above steps for all elements, except for the last one.

    4. Repeat the above steps for fewer and fewer elements each time until there are no pairs of numbers to compare.

    Here, all you need to do is apply the function template and set the type of the element to the template variable, as follows:

    template

    void sort(item *arr)}}

  3. Anonymous users2024-02-05

    I'll give you what to say in your own words.

    Most of the time, when we ordinary programmers write programs, we don't use the basic algorithms you mentioned, and even if we develop databases, SQL language has its own sorting. We use more syntax, logic, software structure, and processes. Most of these algorithms are of concern to senior software developers.

    For example, we know that the array (list) in c has a sorting function, and when we use it, we can directly call the sort method, and the sorting function is completed by the sort method, but we don't need to write **. This sort method is provided by C, but its specific implementation is written by the developers of C, and they have to use what bubbles or something, of course, they must write more than just bubbling, they think deeply, thoroughly, and optimize.

    So don't we use these algorithms?

    Hehe, we still have to use it, we usually use ordinary applications, and there is not much time to use algorithms, and the purpose of teaching us algorithms in schools is to cultivate our logical thinking ability and grammar mastery. But for us, there are a lot of times that are actually available.

    For example, now, you have graduated from undergraduate or graduate school, and the teacher asks you to do a graduation project, and you are asked to do image similarity research. Give you a ** and let you find the 10 most similar images to this ** from the **library. (e.g. face recognition).

    Not to mention the image algorithms, such as edge extraction algorithms, grayscale algorithms, denoising algorithms, these are not to be said, you must figure it out. The one to say is the sort of bubbling you mentioned. You calculated the similarity between the original image and each **, which must be placed in some of your custom classes, structs, and require the output of the most similar 10 sheets, then you can only use these traditional algorithms yourself, and then you can't use them?

  4. Anonymous users2024-02-04

    For example, there is such a problem - use the bubbling algorithm to retrieve the overdue information in the book lending management system, the algorithm is just a small module in the specific program, you can try a small program to find gold coins, one of the n coins is a counterfeit (lighter than the others), many algorithms can be solved.

  5. Anonymous users2024-02-03

    Most programmers don't need these sorts, especially C programmersThe NET Standard Library (BCL) already provides a rich set of data structures, and the internal algorithms are already handled automatically.

  6. Anonymous users2024-02-02

    When the language's built-in functions don't meet your needs, you have to write these algorithms yourself.

Related questions
10 answers2024-03-21

The application does not close, you can start the task manager to close the application. >>>More

10 answers2024-03-21

arp packages can be used in ms's platformsdk in ip helper dword sendarp (ipaddr destip, ipaddr srcip, pulong pmacaddr, pulong phyaddrlen); >>>More

5 answers2024-03-21

The ** provided is mainly based on the following two errors: >>>More

7 answers2024-03-21

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