int main()
{
	int plusTasks=10, minusTasks=10;
	enum {plus, minus} tasktype;
	task tasks;
	time_t seed;
	srand((unsigned int) time(&seed));
	while(plusTasks+minusTasks>0)
	{
		tasktype = rand()%2;
		if(tasktype==plus && plusTasks>0) {
			tasks.first=rand()%100; /*0 to 99 */
			tasks.second=rand()%(100-tasks.first); /*0+(100-first-1)+first=99 */
			tasks.op=tasktype;
			plusTasks--;
			printTask(tasks);
		} else if(tasktype == minus && minusTasks>0) 
		{
			tasks.first = rand()%100; /* 0 to 99*/
			tasks.second = rand()%(tasks.first+1);/*0 to first+1-1  =  0 to first */
			tasks.op=tasktype;
			minusTasks--;
			printTask(tasks);
		}
	}
	return 0;
}
int main()
{
    /// INPUT START
    freopen("input.txt", "r", stdin);
    freopen("debug.txt", "w", stderr);
    int n;
    int m;
    //cout << "input conditions:\n";
    cin >> n >> m;

    vvd a(m, vd(n));
    vd b(m);
    vc type(m);
    vc sign(n);

    for (int i = 0; i < m; ++i)
    {
        cin >> type[i];
        for (int j = 0; j < n; ++j)
            cin >> a[i][j];
        cin >> b[i];
    }

    for (int i = 0; i < n; ++i)
    {
        cin >> sign[i];
    }

    vd c(n);
    for (int i = 0; i < n; ++i)
    {
        cin >> c[i];
    }
    /// INPUT END

    vvd dual_a;
    vd dual_b;
    vd dual_c;

    getCanonicalMatrix(a, b, c, sign, type);
    printTask(a, b, c);

    getDualProblem(a, b, c, dual_a, dual_b, dual_c);
    printTask(dual_a, dual_b, dual_c, "dual_task.txt");

    cout << "Simplex\n";
    printResult(linearProgramming::simplex(a, b, c), sign);
    cout << "\nAll vertexes\n";
    printResult(linearProgramming::allVertexesCheck(a, b, c), sign);
    cout << "\nDual problem simplex\n";
	printResult(linearProgramming::simplex(dual_a, dual_b, dual_c), sign, false);


    return 0;
}
Exemple #3
0
void pq_print(PQueue* q)
{
    int id;
    for(id=q->size-1; id>=q->bot; id--){
        int i = q->elem[id]->tid;
        if(i>=0)
            printTask(i);
    }
}
Exemple #4
0
int main() {
    struct task task1, task2, task3, task4, task5, task6, task7, task8, task9, task10;
	struct DynArr taskList;
	initDynArr(&taskList, 10);

    /* create tasks */
	task1 = createTask(10, "Clean house");
	task2 = createTask(6, "Eat dinner");
	task3 = createTask(2, "Do laundry");
	task4 = createTask(4, "Do dishes");
	task5 = createTask(5, "Grocery shopping");
	task6 = createTask(7, "Change oil");
	task7 = createTask(13, "Do taxes");
	task8 = createTask(8, "Sleep");
	task9 = createTask(1, "Do other homework");
	task10 = createTask(0, "Finish heap homework");

	/* add tasks to the dynamic array */
	addHeap(&taskList, task1);
	addHeap(&taskList, task2);
	addHeap(&taskList, task3);
	addHeap(&taskList, task4);
	addHeap(&taskList, task5);
	addHeap(&taskList, task6);
	addHeap(&taskList, task7);
	addHeap(&taskList, task8);
	addHeap(&taskList, task9);
	addHeap(&taskList, task10);

	printf("Beginning testing... \n");

  /* Should print: heap size: 10 */
  printf("heap size: %d \n", sizeDynArr(&taskList));

  /* Should print - Priority: 0 - Description: Finish heap homework */
  printTask(getMinHeap(&taskList));

  /* Remove top node from head */
	removeMinHeap(&taskList);

  /* Should print - Priority: 1 - Do other homework */
	printTask(getMinHeap(&taskList));

	int i;
	printf("printing heap... \n");
	/* Should print - 1 2 6 4 5 7 13 10 8 9 */
	for(i = 0; i <sizeDynArr(&taskList);i++) {
        printf("%d ", getDynArr(&taskList, i).priority);
	}
	printf("\n");

    /* Sort heap */
	sortHeap(&taskList);

    printf("printing sorted heap... \n");
    /* Should print (without descriptions) : 1, 2, 4, 5, 6, 7, 8, 10, 13 */
		/*Not sure how to both print "Priority: 1 - Do Other homework" like you asked
			above and in this order ascending, using the same function.
			Doesn't really make sense.*/
	for (i = 0; i < taskList.size; i++)	{
	  	printTask(getDynArr(&taskList, i));
	}
    printf("\n");

	return 0;
}