C language (move sort) 2017.4.23__c language

Source: Internet
Author: User
/*1. Move a number of the first elements of an array to the end of the array.
such as input array [1,2,3,4,5] Enter the number of moving digits 2
Output [3,4,5,1,2]

*/


#include <stdio.h>
#define SIZE 1000
int * sort (int *a,int n,int m);
Int main ()
{
    int I, j, count = 1;
    int a[size], n, m;


    scanf ("%d", &n);


    for (i = 0; i < n; i++)
        scanf ("%d", &a[i]);


    scanf ("%d", &m);//Enter exchange several


    for (i=0;i<m;i++)
    & nbsp   a[n+i]=a[i];//The input value to the tail
        sort (a,n,m);


    for (i=0;i<n;i++)
        printf ("%d  ", a[i]);


        return 0;
}
int * sort (int *a,int n,int m)
{
    int i;
    for (i=0;i<n;i++)
        a[i]=a[i+m];//to move the following number forward


        return A;
}

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.