Beispiel #1
0
int main(int argc, const char *argv[])
{
	char game[3][3]={0};
	char key;
	show_game(game,3);
	printf("\n");
	while(scanf(" %c",&key)){
		switch(key){
			case 'w':
				{
			//	printf("%s\033[k");
				system("clear");
				sort_up(game,3);
				move_up(game,3);
				randfunc(game,3);
			        show_game(game,3);
				}
				break;
			case 'a':
				{
		//		printf("%s\033[1J");
				system("clear");  
				sort_left(game,3);
				move_left(game,3);
			        randfunc(game,3);
				show_game(game,3);

				}
				break;

			case 'd':
				{
			//	printf("%s\033[1k");
					system("clear");
					sort_right(game,3);
					move_right(game,3);
					randfunc(game,3);
					show_game(game,3);
				}
				break;
			
			case 's':
				{
		//		printf("%s\033[1J");
				system("clear");  
				sort_down(game,3);
				move_down(game,3);
				randfunc(game,3);
			        show_game(game,3);
				}
				break;

		}
		
	}
	return 0;
}
Beispiel #2
0
/**
 * Deletes the minimum entry according to key.
 * @param[out] heap Non-empty heap.
 */
void
piojo_heap_pop(piojo_heap_t *heap)
{
        size_t lastidx;
        PIOJO_ASSERT(heap);
        PIOJO_ASSERT(piojo_heap_size(heap) > 0);

        lastidx = piojo_array_size(heap->data) - 1;
        if (lastidx > 0){
                swap(0, lastidx, heap);
        }

        piojo_hash_delete(piojo_array_at(lastidx, heap->data),
                          heap->indices_by_data);
        piojo_array_delete(lastidx, heap->data);

        sort_down(0, lastidx, heap);
}
Beispiel #3
0
// Add any additional bitmaps/icons to the internal image list
int wxAdvancedListCtrl::AddImageSmall(wxImage Image)
{
    if (GetImageList(wxIMAGE_LIST_SMALL) == NULL)
    {
        wxImageList *ImageList = new wxImageList(16, 16, true);
        AssignImageList(ImageList, wxIMAGE_LIST_SMALL);
        
        wxBitmap sort_up(16, 16), sort_down(16, 16);
        wxColour Mask = wxColour(255,255,255);
        
        // Draw sort arrows using the native renderer
        {
            wxMemoryDC renderer_dc;

             // sort arrow up
            renderer_dc.SelectObject(sort_up);
            renderer_dc.SetBackground(*wxTheBrushList->FindOrCreateBrush(Mask, wxSOLID));
            renderer_dc.Clear();
            wxRendererNative::Get().DrawHeaderButtonContents(this, renderer_dc, wxRect(0, 0, 16, 16), 0, wxHDR_SORT_ICON_UP);

             // sort arrow down
            renderer_dc.SelectObject(sort_down);
            renderer_dc.SetBackground(*wxTheBrushList->FindOrCreateBrush(Mask, wxSOLID));
            renderer_dc.Clear();
            wxRendererNative::Get().DrawHeaderButtonContents(this, renderer_dc, wxRect(0, 0, 16, 16), 0, wxHDR_SORT_ICON_DOWN);
        }

        // Add our sort icons to the image list
        ImageList_SortArrowDown = GetImageList(wxIMAGE_LIST_SMALL)->Add(sort_down, Mask);
        ImageList_SortArrowUp = GetImageList(wxIMAGE_LIST_SMALL)->Add(sort_up, Mask);
    }
    
    if (Image.IsOk())
    {
        return GetImageList(wxIMAGE_LIST_SMALL)->Add(Image);
    }
    
    return -1;
}