2016 Huawei on-machine problem one (cyclic shift)

Source: Internet
Author: User

1. Loop array shift Enter an array of 10 full numbers, enter a positive integer m, and loop the rear m bits of the array. Calculates the number of the first m and the number of M after the shift. 1 2 3 4 5 6 7 8 9 1038 9 10 1 2 3 4 5 6 727 18
1#include <iostream>2#include <stdio.h>3#include <cmath>4#include <string>5#include <algorithm>6#include <memory.h>7 8 using namespacestd;9 Ten Const DoublePI = ACOs (-1.0); One Const DoubleEPS = 1e-6; A Const DoubleINF = 1e9 +7; -  -  the  - inta[Ten]; - voidExchangeintA[],intBeginintend) - { +     inttemp; -      while(begin<end) +     { Atemp =A[begin]; atA[begin] =A[end]; -A[end] =temp; -begin++; -end--; -     } -  in } -  to intMain () + { -Freopen ("data.in","R", stdin); the      *     intm; $Memset (A,0,Ten);Panax Notoginseng      for(inti =0; I <Ten; i++) -     { theCIN >>A[i]; +     } A      theCIN >>m; +Exchange (A,0,Ten-m-1); -Exchange (A,Ten-M,9); $Exchange (A,0,9); $  -     intBeginsum =0; -     intEndsum =0; the      for(inti =0; I < m; i++) -     {WuyiBeginsum + =A[i]; the  -     } Wu  -      for(intj =9; J >Ten-M-1; j--) About     { $Endsum + =A[j]; -     } -  -      for(inti =0; I <9; i++) A     { +cout << A[i] <<" "; the     } -cout <<a[9] <<Endl; $cout << beginsum <<" "<< Endsum <<Endl; the  theSystem"Pause"); the     return 0; the}

2016 Huawei on-machine problem one (cyclic shift)

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.