C language Problem

Source: Internet
Author: User

1, an array of n integers, so that it moves backward in the order of the first number of M position, the last m number to move to the front

1 /*########################################################################################################### #######2 #3 # An array of n integers, which moves the previous number in the Order of M, and the last m number to the front4 #5 ########################################################################################################## #########*/6 7#include"stdio.h"8#include"stdlib.h"9 Ten #defineN 10 One  A voidMoveint*a,intNintm) - { -     int*p,*q;//*p, *q pointer variable the     intTemp//Zero Variable -  -      for(p=a+n-m; p<a+n; p++) -     { +temp=*p; -  +          for(q=p-1; q>=p+m-n; q--) A* (q+1)=*Q; at  -* (q+1)=temp; -     } -  - } -  in  - intMainvoid) to { +     intA[n]; -     intm,i; the  *printf"Please enter%d number: \ n", N); $      for(i=0; i<n; i++)Panax Notoginsengscanf"%d",&a[i]); -  theprintf"Please enter the number of digits you want to move to the right:"); +scanf"%d",&m); A  the Move (A, N, m); +  -printf"the order of the array elements after the position is moved:"); $      for(i=0; i<n;i++) $printf"%5d", A[i]); -  -System"Pause"); the  -     return 0;Wuyi}
View Code

C language Problem

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.