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)