Huawei machine test-integer array sorting (string input and Output)

Source: Internet
Author: User
#include <stdio.h>/*  Write a program that implements the sorting algorithm, the user enters the certificate sequence, the program sorts all the certificates from small to large and outputs  input: A sequence of numbers, a length of less than 1024, and a comma-delimited number of two digits, All numbers are non-negative integers, the integer number is less than  the total output: sorted integer sequence, two numbers separated by commas */int main (int argc, char *argv[]) {    int a[129];    int i=0;    scanf ("%d", &a[i++]);    char c;    while (scanf ("%c", &c) &&c!= ' \ n ')    {        scanf ("%d", &a[i]);        i++;    }    for (int j=0;j<i;++j) for        (int k=j+1;k<i;++k)        {            if (A[j]>a[k])            {                int t=a[j];                A[J]=A[K];                a[k]=t;            }        }    printf ("%d", a[0]);    for (int k=1;k<i;++k)        printf (",%d", a[k]);    printf ("\ n");    return 0;}

Huawei machine test-integer array sorting (string input and Output)

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.