标签:blog io ar div art c on log amp
自己写的
#include<stdio.h> bool check(int a[],int start,int end); void main() { // int a[]={5,7,6,9,11,10,8}; int a[]={7,4,6,5}; int len=sizeof(a)/sizeof(int); if(check(a,0,len-1)) printf("ok\n"); else printf("not ok\n"); } bool check(int a[],int start,int end) { if(end==start) return 1; int s=start,e=end; while(s<e && a[s]<=a[end]) s++; if(s==e) return 1; int newend=s-1; while(s<e && a[s]>=a[end]) s++; if(s<e || s==e && a[s]<a[end]) return 0; bool one,two; one=check(a,start,newend); two=check(a,newend+1,end-1); return one & two; }
标签:blog io ar div art c on log amp
原文地址:http://www.cnblogs.com/notlate/p/4004235.html