Esempio n. 1
0
void fix(int* array,int n)
{
	int i,j,flg=0;
	int first,last,c;
	if(isSort(array,n)) //Determining the type of Sorting 
	{
		// For Descending Order type of Sorting 
		for(i=0;i<n-1;i++)
		{
			if(array[i]<array[i+1])
			{
				flg=1;
				break;
			}
		}
		first=i;
		while(i<n&&flg)
		{
			if(array[i]<=array[i+1])
				i++;
			else
				break;
		}
		last=i;
		if(i==n)
			last=n-1;
	}
	else
	{
		//For Ascending Order type of Sorting
		for(i=0;i<n-1;i++)
		{
			if(array[i]>array[i+1])
			{
				flg=1;
				break;
			}
		}
		first=i;
		while(i<n-1&&flg)
		{
			if(array[i]>=array[i+1])
				i++;
			else
				break;
		}
		last=i;
	}
	i=first;
	j=last;
	while(i<j)
	{
		c=array[i];
		array[i]=array[j];
		array[j]=c;
		i++;
		j--;
	}
}
Esempio n. 2
0
File: type.cpp Progetto: jinala/CVC4
SortType::SortType(const Type& t) throw(IllegalArgumentException)
    : Type(t) {
  PrettyCheckArgument(isNull() || isSort(), this);
}