To see the solution after the problem
#include <iostream>using namespace Std;typedef int status;//an array p coordinates 0 to I of the element header status Diao_tou (int *p,int i) {if (i ==0) return 1;for (int j=0;j<= (i-1)/2; j + +) {int temp;temp=p[i-j];p [i-j]=p[j];p [J]=temp;} return 1;} int main () {//input 1 to n different numbers, from front to back to the size of each pie from top to bottom, different. int max_size;cin>>max_size;//Enter a number of max_size int *ptr,i=0;ptr = (int *) malloc (max_size*sizeof (int));//The numbers are stored in the array while (1) {cin>>ptr[i];i++;if (i==max_size) is break;} for (int i=0;i<max_size;++i) cout<<ptr[i]<< '; cout<<endl;int cout_time=0;//count variable for (int K=max _SIZE-1;K!=0;--K) {if (ptr[k]==k) continue;if (ptr[0]==k) {Diao_tou (ptr,k); cout_time++;} else{for (int j=1;j!=k;j++) if (ptr[j]==k) {Diao_tou (ptr,j);d Iao_tou (ptr,k); cout_time++;cout_time++;}} cout<< "Cout_time=" <<cout_time<<endl;system ("pause"); return 1;}
Programming Beauty--1.3 A stack of pancakes