C Language Programming Tutorial (third Edition) after class exercise 10.4

Source: Internet
Author: User

1353:c Language Programming Tutorial (third Edition) After class exercise 10.4 time limit:1 Sec Memory limit:128 MB
submit:296 solved:219
[Submit] [Status] [BBS] Description have n integers, so that the previous number of sequential moves backward m position, the last m number into the first number of M, see figure. Write a function: To achieve the above function, in the main function input n number and output adjusted n number. The number of inputs input data n n Integer moved position moutput the number of n after the move, sample input
101 2 3 4 5 6 7 8 9 102
Sample Output


#include <stdio.h>Const  intn=100000;intn,a[n],b[n],m;voidMove () { for(intI=0; i<m; i++) {b[m-1-i]=a[n-1-I.];//another array, from the back to the next, the last few numbers of a array first to make one side    }     for(inti=n-1; i>=0; i--)    {        if(i>=m) A[i]=a[i-m]; if(i<m) A[i]=b[i];//direct assignment to front of array a    }}intMain () { while(SCANF ("%d", &n)! =EOF) {         for(intI=0; i<n; i++) {scanf ("%d",&A[i]); } scanf ("%d",&m);        Move ();  for(intI=0; i<n; i++) {printf ("%d", A[i]); } printf ("\ n"); }    return 0;}

C Language Programming Tutorial (third Edition) after class exercise 10.4

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.