C # -- 2nd week experiment -- Task 12 -- input 10 numbers into the array, and then implement Bubble Sorting

Source: Internet
Author: User

/* (Start of program header annotation)
* Copyright and version Declaration of the program
* Copyright (c) 2011, a student from the computer College of Yantai University
* All rights reserved.
* File name: enter 10 to store the data in the array, and then perform Bubble sorting.
* Author: Lei hengxin
* Completion date: January 1, September 10, 2012
* Version No.: V1.0
* Description of tasks and Solutions
* Input description:
* Problem description:
* Program output:
* End the comment in the program Header
*/
 
Using System;
Using System. Collections. Generic;
Using System. Linq;
Using System. Text;
 
Namespace ConsoleApplication1_mopaopaixu
{
Class Program
{
Static void Main (string [] args)
{
Console. WriteLine ("this is a program 'input 10 numbers into the array, and then implement bubble sorted ...");
Double [] c = new double [10];
For (int number = 0; number <10; ++ number)
{
Console. Write ("Enter the number of {0}:", number + 1 );
// String s = Console. ReadLine ();
C [number] = double. Parse (Console. ReadLine ());
}
Int I, j;
Double m;
For (I = 0; I <10; ++ I)
For (j = 0; j <10-i-1; ++ j)
{
If (c [j]> c [j + 1])
{
M = c [j];
C [j] = c [j + 1];
C [j + 1] = m;
}
}
Console. Write ("10 after the number of bubbles is sorted (in the ascending order :");
Foreach (double var in c)
{
Console. Write (var); // read the elements in the string in sequence
Console. Write ("");

}
Console. ReadKey ();
}
}
}

Running result:


Experience Accumulation:
1. I am familiar with the Bubble Sorting Algorithm again.

Related Article

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.