int main( ) { struct dqueue dq ; int i, n ; system ( "cls" ) ; initdqueue ( &dq ) ; addqatend ( &dq, 11 ) ; addqatbeg ( &dq, 10 ) ; addqatend ( &dq, 12 ) ; addqatbeg ( &dq, 9 ) ; addqatend ( &dq, 13 ) ; addqatbeg ( &dq, 8 ) ; addqatend ( &dq, 14 ) ; addqatbeg ( &dq, 7 ) ; display ( dq ) ; n = count ( dq ) ; printf ( "\nTotal elements: %d", n ) ; i = delqatbeg ( &dq ) ; if ( i != NULL ) printf ( "\nItem extracted = %d", i ) ; i = delqatbeg ( &dq ) ; if ( i != NULL ) printf ( "\nItem extracted = %d", i ) ; i = delqatbeg ( &dq ) ; if ( i != NULL ) printf ( "\nItem extracted = %d", i ) ; i = delqatend ( &dq ) ; if ( i != NULL ) printf ( "\nItem extracted = %d", i ) ; display ( dq ) ; n = count ( dq ) ; printf ( "\nElements Left: %d", n ) ; deldqueue ( &dq ) ; return 0 ; }
int main( ) { int arr[MAX] ; int front, rear, i, n ; // clrscr( ) ; /* initialises data members */ front = rear = -1 ; for ( i = 0 ; i < MAX ; i++ ) arr[i] = 0 ; addqatend ( arr, 17, &front, &rear ) ; addqatbeg ( arr, 10, &front, &rear ) ; addqatend ( arr, 8, &front, &rear ) ; addqatbeg ( arr, -9, &front, &rear ) ; addqatend ( arr, 13, &front, &rear ) ; addqatbeg ( arr, 28, &front, &rear ) ; addqatend ( arr, 14, &front, &rear ) ; addqatbeg ( arr, 5, &front, &rear ) ; addqatend ( arr, 25, &front, &rear ) ; addqatbeg ( arr, 6, &front, &rear ) ; addqatend ( arr, 21, &front, &rear ) ; addqatbeg ( arr, 11, &front, &rear ) ; printf ( "\nElements in a deque: " ) ; display ( arr ) ; n = count ( arr ) ; printf ( "\nTotal number of elements in deque: %d", n ) ; i = delqatbeg ( arr, &front, &rear ) ; printf ( "\nItem extracted: %d", i ) ; i = delqatbeg ( arr, &front, &rear ) ; printf ( "\nItem extracted:%d", i ) ; i = delqatbeg ( arr, &front, &rear ) ; printf ( "\nItem extracted:%d", i ) ; i = delqatbeg ( arr, &front, &rear ) ; printf ( "\nItem extracted: %d", i ) ; printf ( "\nElements in a deque after deletion: " ) ; display ( arr ) ; addqatend ( arr, 16, &front, &rear ) ; addqatend ( arr, 7, &front, &rear ) ; printf ( "\nElements in a deque after addition: " ) ; display ( arr ) ; i = delqatend ( arr, &front, &rear ) ; printf ( "\nItem extracted: %d", i ) ; i = delqatend ( arr, &front, &rear ) ; printf ( "\nItem extracted: %d", i ) ; printf ( "\nElements in a deque after deletion: " ) ; display ( arr ) ; n = count ( arr ) ; printf ( "\nTotal number of elements in deque: %d", n ) ; return 0; //getch( ) ; }