Minimum number of rotated array

Source: Internet
Author: User

Add yourself to the entire program, which contains sort, rotate, find
#include <iostream>using namespace std;void my_sort (int a[],int len) {int temp;for (int i=0;i<len-1;i++) {for ( int j=0;j<len-1-i;j++) {if (a[j]>a[j+1]) {temp = A[j];a[j] = a[j+1];a[j+1] = temp;}}} void My_reverse (int a[],int m, int len) {int Temp;while (m>0) {temp = a[len-1];for (int i=len-2;i>=0;i--) {a[i+1] = A[i] ; }a[0] = temp;m--;}} void My_print (int a[],int len) {for (int i=0;i<len;i++) {cout<<a[i]<< "";} Cout<<endl;} int my_find (int a[],int low,int high) {int min = a[low];for (int i=low+1;i<=high;i++) {if (a[i]<min) {min = A[i];}} return min;}  int my_min (int a[],int len) {int low = 0;int High = Len-1;int mid = Low;while (A[low]>=a[high]) {if (high-low = = 1) {return A[high];} Mid = (Low+high)/2;if (A[low]==a[mid]&&a[mid]==a[high]) return My_find (A,low,high), if (A[mid]>=a[low]) { Low = mid;} else if (A[mid]<=a[high]) {high = mid;}} if (A[low]<a[high]) {return a[low];}} int main () {int a[] = {1,1,1,1,0,1};int len = sizeof (a)/sizeof (a[0]); My_sort (A,len); My_print (A,len);cout<< "input the data for reverse:" <<endl;int m;cin>>m;my_reverse (A,m,len); my_ Print (a,len), int min = my_min (a,len);cout<< "min=" <<min<<endl;return 0;}

Minimum number of rotated array

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: 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.