Exemple #1
0
void tcColorCar(Car car)
{
    LIST *colors, *bubble;
    ubyte choice;
    U32 costs;
    Person marc = (Person) dbGetObject(Person_Marc_Smith);

    costs = (U32)tcColorCosts(car);

    bubble = txtGoKeyAndInsert(BUSINESS_TXT, "LACKIEREN", (U32) costs, NULL);

    SetPictID(marc->PictID);
    Bubble(bubble, 0, 0L, 0L);
    RemoveList(bubble);

    if (Say(BUSINESS_TXT, 0, MATT_PICTID, "LACKIEREN_ANT") == 0) {
	colors = txtGoKey(OBJECTS_ENUM_TXT, "enum_ColorE");

	txtPutCharacter(colors, 0, '*');

	if (tcSpendMoney(costs, 1)) {
	    char exp[TXT_KEY_LENGTH];

	    txtGetFirstLine(BUSINESS_TXT, "NO_CHOICE", exp);
	    ExpandObjectList(colors, exp);

	    if (ChoiceOk
		(choice =
		 Bubble(colors, (ubyte) car->ColorIndex, 0L, 0L), GET_OUT,
		 colors)) {
		car->ColorIndex = (ubyte) choice;

		SetCarColors(car->ColorIndex);
		gfxPrepareRefresh();
		PlayAnim("Umlackieren", 3000, GFX_DONT_SHOW_FIRST_PIC);

		inpSetWaitTicks(200L);

		inpWaitFor(INP_LBUTTONP | INP_TIME);

		StopAnim();
		inpSetWaitTicks(1L);

		gfxRefresh();
		/*gfxShow(26,GFX_NO_REFRESH|GFX_ONE_STEP,0L,-1L,-1L);*/
		/*gfxShow((uword)car->PictID,GFX_NO_REFRESH|GFX_OVERLAY,1L,-1L,-1L);*/
	    }
	}

	RemoveList(colors);
    }

    AddVTime(137);
}
Exemple #2
0
void plLoad(U32 objId)
{
    FILE *fh = NULL;
    ubyte ret;

    if (objId == Building_Starford_Kaserne)
	while ((ret =
		plOpen(objId, PLANING_OPEN_READ_PLAN, &fh)) != PLANING_OPEN_OK);
    else
	ret = plOpen(objId, PLANING_OPEN_READ_PLAN, &fh);

    if (ret == PLANING_OPEN_OK) {
	if (GamePlayMode & GP_GUARD_DESIGN)
	    grdDo(fh, plSys, PersonsList, BurglarsNr, PersonsNr,
		  GUARDS_DO_LOAD);
	else {
	    LIST *l = NULL;
	    ubyte i;
	    ubyte goon = 1;

	    if ((l = LoadSystem(fh, plSys))) {
		inpTurnESC(0);
		Bubble(l, 0, NULL, 0L);
		inpTurnESC(1);
		RemoveList(l);

		goon = 0;
		l = NULL;
	    }

	    if ((l = plLoadTools(fh))) {
		inpTurnESC(0);
		Bubble(l, 0, NULL, 0L);
		inpTurnESC(1);
		RemoveList(l);

		goon = 0;
	    }

	    if (goon) {
		for (i = 0; i < BurglarsNr; i++)
		    LoadHandler(fh, plSys, OL_NR(GetNthNode(PersonsList, i)));
	    }
	}

	dskClose(fh);
    } else {
	if (ret == PLANING_OPEN_ERR_NO_PLAN)
	    plMessage("NO_PLAN", PLANING_MSG_REFRESH | PLANING_MSG_WAIT);
    }
}
Exemple #3
0
void GameWidget::mouseReleaseEvent(QMouseEvent *event)
{
    if(selection.size() < 2 or !selection.contains(getGridPos(event->x(), event->y())))
        return; //nothing selected or mouse pointer not in selection

    //backup
    oldscore = score;
    for(int x = 0; x < grid_size; x++)
        for(int y = 0; y < grid_size; y++)
            old_grid[x][y] = grid[x][y];

    foreach(Box pos, selection) {
        if(use_animations)
            old_grid[pos.x][pos.y].scale_step = num_scale_steps-1;

        grid[pos.x][pos.y] = Bubble(); //remove bubbles
    }

    score += selection.size()*selection.size();
    selection.clear();

    emit enableUndo(true);
    emit activity();

    compressBubbles();

#ifndef Q_WS_MAEMO_5
    mouseMoveEvent(event); //draw selection if there's a new set of connected bubbles
#endif
}
Exemple #4
0
void tcSellCar(U32 ObjectID)
{
    LIST *bubble;
    U32 offer;
    Car car;
    Person marc = (Person) dbGetObject(Person_Marc_Smith);

    car = (Car) dbGetObject(ObjectID);
    offer = tcGetCarTraderOffer(car);

    if (tcRGetCarAge(car) < 1)
	bubble =
	    txtGoKeyAndInsert(BUSINESS_TXT, "ANGEBOT_1", tcRGetCarValue(car),
			      offer, NULL);
    else
	bubble =
	    txtGoKeyAndInsert(BUSINESS_TXT, "ANGEBOT", tcRGetCarValue(car),
			      tcRGetCarAge(car), offer, NULL);

    SetPictID(marc->PictID);
    Bubble(bubble, 0, 0L, 0L);
    RemoveList(bubble);

    if ((Say(BUSINESS_TXT, 0, MATT_PICTID, "VERKAUF")) == 0) {
	tcAddPlayerMoney(offer);

	hasSet(Person_Marc_Smith, ObjectID);
	hasUnSet(Person_Matt_Stuvysunt, ObjectID);
    }

    gfxShow(27, GFX_NO_REFRESH | GFX_ONE_STEP, 0L, -1L, -1L);
    AddVTime(97);
}
Exemple #5
0
// Spawns a new fish. Called by the old fish.
func Hatch(id fish_id)
{
	for (var i = 0; i < 5; ++i)
		Bubble(1, RandomX(-5, 5), RandomX(-5, 5));
	var fish = CreateObject(fish_id, 0, 0, GetOwner());
	fish->SetCon(1);
	AddEffect("FastGrow", fish, 1, 1, nil, GetID());
	RemoveObject();
}
	void ChangeToPhase1()
    {
        // Set phase var
        mPhase = 1;

        // Play sound, and send text.
		/*_unit->SendChatMessage(CHAT_MSG_MONSTER_SAY, LANG_UNIVERSAL, "Light, give me strength!");
		       ^^ Notes for myself */ 
		Bubble(); 
		Boom();
    }
Exemple #7
0
U32 tcPersonWanted(U32 persId)
{
    U32 hours, i = 0, caught = 0;
    Person john = dbGetObject(Person_John_Gludo);
    Person miles = dbGetObject(Person_Miles_Chickenwing);
    LIST *bubble;
    LIST *jobs = txtGoKey(OBJECTS_ENUM_TXT, "enum_JobE");
    char line[TXT_KEY_LENGTH], name[TXT_KEY_LENGTH];

    dbGetObjectName(persId, name);

    bubble = txtGoKey(BUSINESS_TXT, "BURGLAR_RECOG");

    sprintf(line, "%s %s.", NODE_NAME(GetNthNode(bubble, 3)), name);

    RemoveNode(bubble, NODE_NAME(GetNthNode(bubble, 3)));
    CreateNode(bubble, 0L, line);

    SetPictID(john->PictID);
    Bubble(bubble, 0, 0L, 0L);
    RemoveList(bubble);

    Say(BUSINESS_TXT, 0, miles->PictID, "ARREST_HIM");
    livesInUnSet(London_London_1, persId);
    tcMoveAPerson(persId, Location_Nirvana);

    hours = CalcRandomNr(4L, 7L);

    while ((i++) < hours) {
	AddVTime(60);
	inpDelay(35);
	ShowTime(2);
    }

    if (tcGuyCanEscape(dbGetObject(persId)) > CalcRandomNr(100, 255)) {	/* Flucht gelingt */
	Say(BUSINESS_TXT, 0, john->PictID, "ESCAPED");

	livesInSet(London_Escape, persId);
    } else {			/* nicht */

	Say(BUSINESS_TXT, 0, john->PictID, "ARRESTED");

	livesInSet(London_Jail, persId);

	caught = tcPersonQuestioning(dbGetObject(persId));
    }

    RemoveList(jobs);

    return caught;
}
Exemple #8
0
void driver( enum sort atype, int *array, int elements,
            int random, int delay_factor )
{

switch( atype )
  {
	/* 所有排序算法 */
   case all    :
	/* 冒泡排序 */
   case bubble :
            Setscreen( array, elements, random );
            gprintf( &xaxis, &yaxis, *(sorts + bubble) );
            Bubble( array, elements, delay_factor );
            if ( atype != all ) break; else delay( 1350 );
	/* 延迟交换排序 */
   case delayed:
            Setscreen( array, elements, random );
            gprintf( &xaxis, &yaxis, *(sorts + delayed) );
            Delayed( array, elements, delay_factor );
            if ( atype != all ) break; else delay( 1350 );
	/* 希尔排序 */
   case shell  :
            Setscreen( array, elements, random );
            gprintf( &xaxis, &yaxis, *(sorts + shell ));
            Shell( array, elements, delay_factor );
            if ( atype != all ) break; else delay( 1350 );
	/* Metzner希尔排序 */
   case shell_metzner:
            Setscreen( array, elements, random );
            gprintf( &xaxis, &yaxis, *(sorts + shell_metzner) );
            Shell_Metzner( array, elements, delay_factor );
            if ( atype != all ) break; else delay( 1350 );
	/* 快速排序 */
   case quick  :
            Setscreen( array, elements, random );
            gprintf( &xaxis, &yaxis, *(sorts + quick) );
            Quicksort( array, 0, elements - 1, delay_factor );
            if ( atype != all ) break; else delay( 1350 );
	/* 插入排序 */
   case insertion:
            Setscreen( array, elements, random );
            gprintf( &xaxis, &yaxis, *(sorts + insertion) );
            Insertion( array, elements, delay_factor );
            if ( atype != all ) break; else delay( 1350 );
	/* 停止 */
   case stop:

   default:;
  }
}
Exemple #9
0
U32 tcChooseCar(U32 backgroundNr)
{
    LIST *bubble;
    U32 carCount, carID = 0L;
    ubyte choice;
    Car matts_car;

    hasAll(Person_Matt_Stuvysunt,
	   OLF_PRIVATE_LIST | OLF_INCLUDE_NAME | OLF_INSERT_STAR, Object_Car);
    bubble = ObjectListPrivate;

    if (!(LIST_EMPTY(bubble))) {
	carCount = GetNrOfNodes(bubble);

	if (carCount == 1) {
	    carID = OL_NR(LIST_HEAD(bubble));
	    choice = 1;
	} else {
	    char exp[TXT_KEY_LENGTH];

	    txtGetFirstLine(BUSINESS_TXT, "NO_CHOICE", exp);
	    ExpandObjectList(bubble, exp);

	    Say(BUSINESS_TXT, 0, 7, "ES GEHT UM..");

	    if (ChoiceOk((choice = Bubble(bubble, 0, 0L, 0L)), GET_OUT, bubble))
		carID = OL_NR(GetNthNode(bubble, (U32) choice));
	    else
		choice = GET_OUT;
	}

	if (choice != GET_OUT) {
	    matts_car = (Car) dbGetObject(carID);
	    SetCarColors((ubyte) matts_car->ColorIndex);
	    gfxShow(backgroundNr, GFX_NO_REFRESH | GFX_ONE_STEP, 0L, -1L, -1L);
	    gfxShow((uword) matts_car->PictID, GFX_NO_REFRESH | GFX_OVERLAY, 1L,
		    -1L, -1L);
	}
    }

    RemoveList(bubble);

    return (carID);
}
Exemple #10
0
void tcCarGeneralOverhoul(Car car)
{
    Person marc = dbGetObject(Person_Marc_Smith);
    LIST *bubble;
    ubyte choice;

    SetPictID(marc->PictID);

    bubble =
	txtGoKeyAndInsert(BUSINESS_TXT, "GENERAL_OVERHOUL",
			  (U32) ((tcCostsPerTotalRepair(car) * 255) / 8), NULL);
    Bubble(bubble, 0, 0L, 0L);
    RemoveList(bubble);

    choice = Say(BUSINESS_TXT, 0, MATT_PICTID, "GENERAL_OVERHOUL_QUEST");

    if (choice == 0)
	tcRepairCar(car, "TotalRepair");
}
Exemple #11
0
void plSaveChanged(U32 objId)
{
    if (PlanChanged) {
	LIST *l = txtGoKey(PLAN_TXT, "PLAN_CHANGED");

	inpTurnESC(0);

	if (Bubble(l, 0, NULL, 0L) == 0) {
	    inpTurnESC(1);

	    if (!plAllInCar(objId))
		plSay("PLAN_NOT_FINISHED", 0);

	    plSave(objId);
	} else
	    inpTurnESC(1);

	RemoveList(l);
    }
}
Exemple #12
0
//start new game, fill grid with bubbles
void GameWidget::restart()
{
    emit enableUndo(false);

    score = 0;
    selection.clear();

    //seed field with random non-empty bubbles (values 1..num_colors)
    for(int x = 0; x < grid_size; x++) {
        for(int y = 0; y < grid_size; y++) {
            grid[x][y] = Bubble(double(rand())/(RAND_MAX+1.0)*num_colors+1);

            if(use_animations) {
                grid[x][y].xoffset = grid_size + (width() - grid_size*(bubblesize+margin))/bubblesize/2;
                grid[x][y].xspeed = initial_speed;
            }
        }
    }

    if(use_animations)
        timer->start();

    update();
}
Exemple #13
0
static U32 tcATraitor(U32 traitorId)
{
    char name[TXT_KEY_LENGTH], line[TXT_KEY_LENGTH];
    LIST *bubble = txtGoKey(BUSINESS_TXT, "A_TRAITOR");
    LIST *newList = CreateList();
    Person john = dbGetObject(Person_John_Gludo);

    dbGetObjectName(traitorId, name);
    sprintf(line, NODE_NAME(LIST_HEAD(bubble)), name);

    CreateNode(newList, 0L, line);
    CreateNode(newList, 0L, NODE_NAME(GetNthNode(bubble, 1)));
    CreateNode(newList, 0L, NODE_NAME(GetNthNode(bubble, 2)));

    SetPictID(john->PictID);
    Bubble(newList, 0, 0L, 0L);

    RemoveList(bubble);
    RemoveList(newList);

    Say(BUSINESS_TXT, 0, john->PictID, "ARRESTED");

    return 1;			/* gefangen! */
}
Exemple #14
0
ubyte plSay(char *msg, U32 persId)
{
    register LIST *l = txtGoKey(PLAN_TXT, msg);
    register ubyte choice;

    SetPictID(((Person) dbGetObject(OL_NR(GetNthNode(PersonsList, persId))))->
	      PictID);

    inpTurnESC(0);
    inpTurnFunctionKey(0);

    choice = Bubble(l, 0, NULL, 200);

    inpTurnFunctionKey(1);
    inpTurnESC(1);

    RemoveList(l);


    plDisplayTimer(0, 1);
    plDisplayInfo();

    return choice;
}
Exemple #15
0
main()
{
  Bubble();
  exit(0);
}
Exemple #16
0
func Destruction()
{
	Bubble(5);
}
Exemple #17
0
//let bubbles fall down / move stacks to right
void GameWidget::compressBubbles()
{
    for(int x = grid_size-1; x >= 0; x--) {
        int hole = -1;
        int holes = 0;
        bool bubble_found = false;
        for(int y = 0; y <= grid_size; y++) {
            if(y == grid_size or grid[x][y].color) { //not empty
                if(holes) { //hole found, move bubbles down
                    for(int i = hole; i > 0; i--) {
                        grid[x][i] = grid[x][i-holes];

                        if(use_animations) {
                            grid[x][i].yoffset = holes;
                            grid[x][i].yspeed = initial_speed;
                        }
                    }
                    for(int i = 0; i < holes; i++)
                        grid[x][i] = Bubble();
                }
                bubble_found = true;
                hole = -1;
                holes = 0;
            } else if(bubble_found) {
                hole = y;
                holes++;
            }
        }
    }

    for(int x = grid_size-1; x >= 0; x--) {
        if(!grid[x][grid_size-1].color) { //collumn empty
            //shift remaining collums
            int x2 = x;
            while(--x2 >= 0) {
                for(int y = 0; y < grid_size; y++) {
                    grid[x2+1][y] = grid[x2][y];

                    if(use_animations) {
                        grid[x2+1][y].xoffset += 1;
                        grid[x2+1][y].xspeed = initial_speed;
                    }
                }
            }

            //add new collumn
            const int height = int(double(rand())/(RAND_MAX + 1.0)*grid_size);
            for(int y = grid_size-1; y >= height; y--) {
                grid[0][y] = Bubble(double(rand())/(RAND_MAX + 1.0)*num_colors+1);

                if(use_animations) {
                    grid[0][y].scale_step = num_scale_steps-1;
                }
            }

            //erase remains of old collumn
            for(int y = height-1; y >= 0; y--)
                grid[0][y] = Bubble();

            x++; //make sure to run over collumn again
        }
    }
    if(use_animations)
        timer->start();

    update();
    checkGameOver();
}
Exemple #18
0
void tcBuyCar(void)
{
    LIST *bubble = NULL;
    ubyte choice = 0, choice1 = 0;
    Car matts_car;
    Person marc = (Person) dbGetObject(Person_Marc_Smith);

    while ((choice1 != 2) && (choice != GET_OUT)) {
	ObjectListSuccString = tcShowPriceOfCar;
	ObjectListWidth = 48;

	hasAll(Person_Marc_Smith,
	       OLF_ALIGNED | OLF_PRIVATE_LIST | OLF_INCLUDE_NAME |
	       OLF_INSERT_STAR | OLF_ADD_SUCC_STRING, Object_Car);
	bubble = ObjectListPrivate;

	ObjectListSuccString = NULL;
	ObjectListWidth = 0;

	if (!(LIST_EMPTY(bubble))) {
	    char exp[TXT_KEY_LENGTH];

	    txtGetFirstLine(BUSINESS_TXT, "THANKS", exp);
	    ExpandObjectList(bubble, exp);

	    ShowMenuBackground();

	    if (ChoiceOk(choice = Bubble(bubble, 0, 0L, 0L), GET_OUT, bubble)) {
		matts_car =
		    (Car)
		    dbGetObject(((struct ObjectNode *)
				 GetNthNode(bubble, (U32) choice))->nr);

		SetCarColors((ubyte) matts_car->ColorIndex);
		gfxShow((uword) matts_car->PictID, GFX_NO_REFRESH | GFX_OVERLAY,
			0L, -1L, -1L);

		if (Present
		    (((struct ObjectNode *) GetNthNode(bubble, (U32) choice))->
		     nr, "Car", InitCarPresent)) {
		    choice1 = Say(BUSINESS_TXT, 0, MATT_PICTID, "AUTOKAUF");

		    AddVTime(7);

		    if (choice1 == 1) {
			U32 price = tcGetCarPrice(matts_car);

			if (tcSpendMoney(price, 0)) {
			    U32 carID =
				((struct ObjectNode *)
				 GetNthNode(bubble, (U32) choice))->nr;

			    hasSet(Person_Matt_Stuvysunt, carID);
			    hasUnSet(Person_Marc_Smith, carID);

			    Say(BUSINESS_TXT, 0, marc->PictID, "GOOD CAR");
			}

			if (Say(BUSINESS_TXT, 0, MATT_PICTID, "NACH_AUTOKAUF")
			    == 1)
			    choice1 = 2;
		    }
		}

		gfxShow(27, GFX_NO_REFRESH | GFX_ONE_STEP, 0L, -1L, -1L);
	    } else
		choice = GET_OUT;
	} else {
	    Say(BUSINESS_TXT, 0, marc->PictID, "NO_CAR");
	    choice = GET_OUT;
	}

	RemoveList(bubble);
    }
}
Exemple #19
0
ubyte plOpen(U32 objId, ubyte mode, FILE ** fh)
{
    if (GamePlayMode & GP_GUARD_DESIGN) {
	if (grdInit(fh, Planing_Open[mode], objId, lsGetActivAreaID()))
	    return PLANING_OPEN_OK;
    } else {
	register LIST *PlanList;
	register ubyte i;
	FILE *pllFh;
	U32 pllData = 0;
	char pllPath[DSK_PATH_MAX], pllPath2[DSK_PATH_MAX],
	    name1[TXT_KEY_LENGTH], name2[TXT_KEY_LENGTH], exp[TXT_KEY_LENGTH];

	dbGetObjectName(lsGetActivAreaID(), name1);
	name1[strlen(name1) - 1] = '\0';

	/* MOD 25-04-94 HG - new paths on pc */
	sprintf(name2, "%s%s", name1, PLANING_PLAN_LIST_EXTENSION);

	dskBuildPathName(DISK_CHECK_FILE, DATADISK, name2, pllPath);

	if ((pllFh = dskOpen(pllPath, "rb"))) {
	    fscanf(pllFh, "%" SCNu32, &pllData);
	    dskClose(pllFh);

	    if ((mode == PLANING_OPEN_WRITE_PLAN) || pllData) {
		sprintf(name2, "MODE_%d", mode);
		plMessage(name2, PLANING_MSG_REFRESH);

		PlanList = CreateList();

		dbGetObjectName(objId, name1);

		exp[0] = EOS;

		for (i = 0; i < PLANING_NR_PLANS; i++) {
		    if ((mode == PLANING_OPEN_WRITE_PLAN)
			|| (pllData & (1L << i))) {
			struct IOData *data;

			if (mode == PLANING_OPEN_WRITE_PLAN) {
			    if (pllData & (1L << i))
				txtGetFirstLine(PLAN_TXT, "ATTENTION_1", exp);
			    else
				txtGetFirstLine(PLAN_TXT, "ATTENTION_2", exp);
			}

			sprintf(name2, "*%s Plan %d    %s", name1, i + 1, exp);

			if ((data =
			     CreateNode(PlanList, sizeof(struct IOData),
					name2)))
			    data->io_Data = i;
		    }
		}

		sprintf(name2, "EXPAND_MODE_%d", mode);
		txtGetFirstLine(PLAN_TXT, name2, exp);
		ExpandObjectList(PlanList, exp);

		i = Bubble(PlanList, 0, NULL, 0L);

		if (ChoiceOk(i, GET_OUT, PlanList)) {
		    struct IOData *data;

		    if ((data = GetNthNode(PlanList, i)))
			i = data->io_Data;

		    dbGetObjectName(lsGetActivAreaID(), name1);
		    name1[strlen(name1) - 1] = '\0';

		    sprintf(name2, "%s%d%s", name1, i + 1,
			    PLANING_PLAN_EXTENSION);

		    dskBuildPathName(DISK_CHECK_FILE, DATADISK, name2, pllPath2);

		    *fh = dskOpen(pllPath2, Planing_Open[mode]);

		    if (mode == PLANING_OPEN_WRITE_PLAN) {
			pllData |= 1L << i;

			if ((pllFh = dskOpen(pllPath, "wb"))) {
			    fprintf(pllFh, "%" PRIu32, pllData);
			    dskClose(pllFh);
			}
		    }

		    if (*fh) {
			RemoveList(PlanList);
			return PLANING_OPEN_OK;
		    } else
			ErrorMsg(Disk_Defect, ERROR_MODULE_PLANING, 0);
		}

		RemoveList(PlanList);

		return PLANING_OPEN_ERR_NO_CHOICE;
	    }

	    return PLANING_OPEN_ERR_NO_PLAN;
	}
    }

    ErrorMsg(Disk_Defect, ERROR_MODULE_PLANING, 0);
    return 0;
}
Exemple #20
0
int main(void) {
	int i, count=0;
	int sort, order, size, tmp;
	int *a;
	char row[100], name[100];
	data_t d;
	FILE *fp;
	
	printf("ファイル名:");
	scanf("%s", name);
	
	fp=fopen(name,"r");
	if (fp==NULL) {
		printf("can't open a file\n");
		exit(1);
	}
	
	a = (int *)malloc(sizeof(int)*100);
	tmp = 100;
	
	while(fgets(row, sizeof(row), fp) != NULL) {
		a[count] = atoi(row);
		count++;
		if (count == tmp) {
			a = (int *)realloc(a, sizeof(int)*(tmp+100));
			tmp += 100;
		}
	}
	
	fclose(fp);
	
	printf("| バブルソート : 1, 選択ソート : 2, 挿入ソート : 3 | ");
	scanf("%d", &sort);
	printf("| 昇順 : 1, 降順 : 2 | ");
	scanf("%d", &order);
	
	if (sort == 1) {
		if (order == 1) {
			d = Bubble(a, count, 1);
		} else {
			d = Bubble(a, count, 0);
		}
	} else if (sort == 2) {
		if (order == 1) {
			d = Selection(a, count, 1);
		} else {
			d = Selection(a, count, 0);
		}
	} else {
		if (order == 1) {
			d = Insertion(a, count, 1);
		} else {
			d = Insertion(a, count, 0);
		}
	}
	
	printf("結果:\n");
	for (i=0; i<count; i++) {
		printf("%2d ", a[i]);
		if ((i+1)%20==0) printf("\n");
	}
	printf("\n\n");
	printf("CPUタイム %.7lfs\n交換回数 %d回\n", d.prTime, d.num);
	free(a);
}
// Initialize collection with 50 random elements
BubbleCollection::BubbleCollection() {
    for (int i = 0; i < 50; i++) {
        collection.push_back(Bubble());
    }
}
Exemple #22
0
void BubbleSort(T a[], int n)
{// Sort a[0:n - 1] using bubble sort.
   for (int i = n; i > 1; i--)
      Bubble(a, i);
}