Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int Val_stock_twice(int a[], int n)
- {
- int max = 0;
- int vtMax=0,vtMin=0;
- for (int i = 0; i < n - 1; i++)
- {
- for (int j = i + 1; j < n; j++)
- {
- if (a[j] - a[i] > max)
- {
- max = a[j] - a[i];
- vtMin=i;
- vtMax=j;
- }
- }
- }
- int temp1[100];
- for(int i=0;i<vtMin;i++)
- temp1[i]=a[i];
- int max1=Val_stock(temp1,vtMin);
- int temp2[100];
- for(int i=vtMax+1;i<n;i++)
- temp2[i-vtMax-1]=a[i];
- int max2=Val_stock(temp2,n-vtMax-1);
- if(max2>max1)
- return max+max2;
- return max+max1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement