예제 #1
0
int main()
{
   const char *colFmts[] = {" %-5.5s"," %-5.5s"," %-9.9s"};
   String r1[] = { "a101", "red",  "Java" };
   String r2[] = { "ab40", "gren", "Smalltalk" };
   String r3[] = { "ab9",  "blue", "Fortran" };
   String r4[] = { "ab09", "ylow", "Python" };
   String r5[] = { "ab1a", "blak", "Factor" };
   String r6[] = { "ab1b", "brwn", "C Sharp" };
   String r7[] = { "Ab1b", "pink", "Ruby" };
   String r8[] = { "ab1",  "orng", "Scheme" };

   String *rows[] = { r1, r2, r3, r4, r5, r6, r7, r8 };
   struct sTable table;
   table.rows = rows;
   table.n_rows = 8;
   table.n_cols = 3;

   sortTable(&table, "");
   printf("sort on col 0, ascending\n");
   printTable(&table, stdout, colFmts);

   sortTable(&table, "ro", 1, &cmprStrgs);
   printf("sort on col 0, reverse.special\n");
   printTable(&table, stdout, colFmts);

   sortTable(&table, "c", 1);
   printf("sort on col 1, ascending\n");
   printTable(&table, stdout, colFmts);

   sortTable(&table, "cr", 2, 1);
   printf("sort on col 2, reverse\n");
   printTable(&table, stdout, colFmts);
   return 0;
}
예제 #2
0
// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
void MNcursesPlugin::readUserInput() {
	while ( true ) {
		int ch = getch();
		if ( ch == '<' ) {
			int idx = findTag(_activeTag);
			if ( idx >= 0 ) {
				if ( --idx < 0 ) idx = _tagOrder.size() - 1;
				_activeTag = _tagOrder[idx];
				printTable(_clientTableCache);
			}
		}
		else if ( ch == '>' ) {
			int idx = findTag(_activeTag);
			if ( idx >= 0 )  {
				idx = (idx + 1) % _tagOrder.size();
				_activeTag = _tagOrder[idx];
				printTable(_clientTableCache);
			}
		}
		else if (  ch == 'r' ) {
			_reverseSortOrder = !_reverseSortOrder;
			printTable(_clientTableCache);
		}
	}
}
예제 #3
0
int main ()
{
  printf ("Table of gallon/pint to liter equivalents\n");
  printTable (toLiters);

  printf ("\n\nTable of feet/inch to centimenter equivalents\n");
  printTable (toCenti); 

 return 0;
}
예제 #4
0
int main(void)
{
    int arr_size = 10;
    int arr[arr_size];
    char *strings[10] = {"str01", "str02", "str03", "str04", "str05", "str06", "str07", "str08", "str09", "str10"};
    for(int i = 0; i < arr_size; i++) {
        arr[i] = i;
    }
    
    bl_hashtable *ht = bl_hashtable_new(10);
    
    for(int i = 0; i < arr_size; i++) {
        bl_hashtable_insert(ht, strings[i], strlen(strings[i]) + 1, &arr[i]);
    }
    printTable(ht);
    printf("count = %lu\n", bl_hashtable_count(ht));
    /*
    bl_hashtable_remove(ht, strings[0], strlen(strings[0]) + 1);
    bl_hashtable_remove(ht, strings[6], strlen(strings[6]) + 1);
    bl_hashtable_remove(ht, strings[9], strlen(strings[9]) + 1);
    bl_hashtable_remove(ht, strings[5], strlen(strings[5]) + 1);
    */
    
    int newInt = 60;
    int newInt2 = 78;
    // return ptr to old data
    printf("changed data = %d\n", *(int *)bl_hashtable_modify(ht, strings[6], strlen(strings[6]) + 1, &newInt));
    // had to create new elm, returned ptr to new data
    printf("'modified' new data = %d\n", *(int *)bl_hashtable_modify(ht, "newString", strlen("newString") + 1, &newInt2));
    
    printf("\n");
    printTable(ht);
    printf("count = %lu\n", bl_hashtable_count(ht));
    
    int user_int = 5;
    bl_hashtable_foreach(ht, &user_int, (plus));
    
    printf("\n");
    printTable(ht);
    printf("count = %lu\n", bl_hashtable_count(ht));
    
    printf("\n");
    bl_hashtable_rehash(ht, 6);
    printTable(ht);
    printf("count = %lu\n", bl_hashtable_count(ht));
    
    bl_hashtable_foreach_remove(ht, NULL, NULL);
    //bl_hashtable_free(ht); // gets rid of the hash entirely
    
    printf("\n");
    printTable(ht);
    printf("count = %lu\n", bl_hashtable_count(ht));
    
    return 0;
}
예제 #5
0
void printAllTables(){
	printf("INITIAL TABLE\n");
	printTable(initialTable);
	
	printf("\n");
	int i;
	for(i = 0; i < NUMOFSYMBOL; i++){
		printf("\nTABLE %d\n", i);
		printTable(tables[i]);
	}
}
void BipartiteWeightedMatchingBinding::bindFunctUnitInState(raw_ostream &out,
        State* state, std::string funcUnitType, int numFuncUnitsAvail,
        AssignmentInfo &assigned) {
    // create a numFuncUnitsAvail x numFuncUnitsAvail matrix of integer weights
    // and assignments for solving the bipartite weighted matching problem
    Table weights(numFuncUnitsAvail, std::vector<int>(numFuncUnitsAvail));
    Table assignments(numFuncUnitsAvail, std::vector<int>(numFuncUnitsAvail));

    std::string tmp;
    raw_string_ostream weights_stream(tmp);

    // loop over all operations in this state
    int operationIdx = 0;
    for (State::iterator instr = state->begin(), ie = state->end();
            instr != ie; ++instr) {

        Instruction *I = *instr;
        if (shareInstructionWithFU(I, funcUnitType)) {
            constructWeights(weights_stream, I, operationIdx, funcUnitType,
                    numFuncUnitsAvail, assigned, weights);
            opInstr[operationIdx] = I;
            operationIdx++;
        }
    }

    // only share if there is more than one operation using
    // this functional unit
    int numOperationsToShare = operationIdx;
    if (numOperationsToShare >= 1) {
        out << "State: " << state->getName() << "\n";
        out << "Binding functional unit type: " << funcUnitType << "\n";
        out << "Weight matrix for operation/function unit matching:\n";
        weights_stream.flush();
        out << weights_stream.str();
        printTable(out, funcUnitType, numOperationsToShare, numFuncUnitsAvail,
                weights);

        out << "Solving Bipartite Weighted Matching (minimize weights)...\n";
        solveBipartiteWeightedMatching(weights, assignments);
        out << "Assignment matrix after operation/function unit matching:\n";
        printTable(out, funcUnitType, numOperationsToShare, numFuncUnitsAvail,
                assignments);

        out << "Checking that every operator was assigned to a functional unit...";
        CheckAllWereAssigned(numOperationsToShare, numFuncUnitsAvail,
                assignments);
        out << "yes\n";

        out << "Binding operator -> functional unit assignments:\n";
        UpdateAssignments(out, numOperationsToShare, funcUnitType,
                numFuncUnitsAvail, assigned, assignments);
    }
}
예제 #7
0
void printTables(){
    printf("\n-- Instruction Table --\n\n");
    printInstructionTable();

    printf("\n-- Symbol Table --\n\n");
    printTable(&symbolTable);

    printf("\n-- Jump Table --\n\n");
    printTable(&jumpTable);

    printf("\n-- Stack --\n\n");
    printStack(&stack);
}
예제 #8
0
파일: las.c 프로젝트: JPoirier55/CS157
int main(int argc, char *argv[]){
	
	char fileName[30],heroName[30],super[30],appear[6];
	char slash[2],slash2[2], command[10] = "null";
	char newLine;
	
	if(argc == 3){
		strcpy(command, argv[2]);
		strcpy(fileName, argv[1]);
	}else if(argc ==2){
		strcpy(fileName, argv[1]);
	}else{
		printErr(argv[0]);
		return -1;
	}
	FILE *f = fopen(fileName, "r");
	if(f ==NULL){
		fprintf(stderr,"Error opening file %s.\n", fileName);
		return 42;
	}
	
	
	struct Hero heroes[100];
	int count = 0;
	while(fscanf(f,"%[^/]%[/]%[^/]%[/]%s%c",heroName,slash, super,slash2, appear,&newLine)==6){
		strcpy(heroes[count].name,heroName);
		strcpy(heroes[count].super,super);
		strcpy(heroes[count].appear,appear);
		count++;			
	}
	
	if(strcmp(command,"plain")==0){
		qsort(heroes,count,sizeof(struct Hero),compare_name);
		printTable(heroes,command,count);	
	}else if(strcmp(command,"super")==0){
		qsort(heroes,count,sizeof(struct Hero),compare_super);
		printTable(heroes,command,count);
	}else if(strcmp(command,"appear")==0){
		qsort(heroes,count,sizeof(struct Hero), compare_appear);
		printTable(heroes,command,count);	
	}else if(strcmp(command,"null")==0){
		printTable(heroes,command,count);
	}else{
		printErr(argv[0]);
	}
	
	fclose(f);
	return 0;

}
예제 #9
0
파일: main.cpp 프로젝트: CCJY/coliru
int main()
{
    constexpr std::size_t R = 5;
    constexpr std::size_t C = 5;
    
    int table[R][C] { };
    
    printTable(table, R);
    
    *(*(table + 0) + 0) = 100;
    *(*(table + 1) + 1) = 200;
    
    printTable(table, R);
}
예제 #10
0
void PrintLayout::print()
{
	// we call setup each time to check if the printer properties have changed
	setup();
	if (pageW == 0 || pageH == 0) {
		QMessageBox msgBox;
		msgBox.setIcon(QMessageBox::Critical);
		msgBox.setText(tr("Subsurface cannot find a usable printer on this system!"));
		msgBox.setWindowIcon(QIcon(":subsurface-icon"));
		msgBox.exec();
		return;
	}
	switch (printOptions->type) {
	case print_options::PRETTY:
		printProfileDives(3, 2);
		break;
	case print_options::ONEPERPAGE:
		printProfileDives(1, 1);
		break;
	case print_options::TWOPERPAGE:
		printProfileDives(2, 1);
		break;
	case print_options::TABLE:
		printTable();
		break;
	}
}
예제 #11
0
void moveSpace(Puzzle *puzzle, const Table nextmap, const Position pos) {
	int x = puzzle->space.x;
	int y = puzzle->space.y;
	dputs("moveSpace");
	dcode(printf("px=%d py=%d\n", pos.x, pos.y));
	dcode(printTable("nextmap", nextmap));
	while (pos.x != x || pos.y != y) {
		dcode(printf("x=%d y=%d nm=%d\n", x, y, nextmap[y][x]));
		switch (nextmap[y][x]) {
		case MOVE_LEFT:
			moveLeftSpace(puzzle);
			break;
		case MOVE_RIGHT:
			moveRightSpace(puzzle);
			break;
		case MOVE_UP:
			moveUpSpace(puzzle);
			break;
		case MOVE_DOWN:
			moveDownSpace(puzzle);
			break;
		default:
			dputs("return");
			return;
		}
		x = puzzle->space.x;
		y = puzzle->space.y;
	}
	dputs("end");
}
예제 #12
0
void CDebugHelper::printStackValue(lua_State* pState, int index)
{
    int type = lua_type(pState, index);
    switch(type)
    {
        case LUA_TNUMBER:
                printf("%g\n", lua_tonumber(pState, index));
                break;
        case LUA_TSTRING:
                printf("%s\n", lua_tostring(pState, index));
                break;
        case LUA_TBOOLEAN:
                printf("%d\n", int(lua_toboolean(pState, index)));
                break;
        case LUA_TTABLE:
                printTable(pState, index);
                break;
        case LUA_TTHREAD:
        case LUA_TFUNCTION:
        case LUA_TUSERDATA:
        case LUA_TLIGHTUSERDATA:
                printf("%s:%p\n", lua_typename(pState, type), lua_topointer(pState, -1));
                break;
        default:
                printf("nil value\n");
                break;
    }
}
예제 #13
0
//------------------------------------------------------------------------------
void ofxLua::printTable(luabind::object table, int numTabs) {
	
	string tabs;
	for(int i = 0; i < numTabs; ++i) {
		tabs += "\t";
	}
	
	stringstream line;
	for(luabind::iterator iter(table), end; iter != end; ++iter) {
		line << tabs << iter.key() << " "
			 << (string) lua_typename(L, luabind::type(*iter));
		if(luabind::type(*iter) == LUA_TTABLE) {
			ofLogNotice("ofxLua") << line.str();
			printTable(luabind::object(*iter), numTabs+1);
		}
		else {
			// only print valid values
			switch(luabind::type(*iter)) {
				case LUA_TBOOLEAN:
					ofLogNotice("ofxLua") << line.str() << ": " << (bool) (*iter);
					break;
				case LUA_TNUMBER:
					ofLogNotice("ofxLua") << line.str() << ": " << (*iter);
					break;
				case LUA_TSTRING:
					ofLogNotice("ofxLua") << line.str() << ": \"" << (*iter) << "\"";
					break;
				default:
					ofLogNotice("ofxLua") << line.str();
					break;
			}
		}
		line.str("");
	}
}
예제 #14
0
//--------------------------------------------------------------------
void ofxLua::printGlobals() {
	luabind::object o(luabind::from_stack(L, LUA_GLOBALSINDEX));
	for(luabind::iterator iter(o), end; iter != end; ++iter) {
		if(iter.key() != "_G" && iter.key() != "package") {
			
			// only print valid values
			switch(luabind::type(*iter)) {
				case LUA_TBOOLEAN:
				case LUA_TNUMBER:
				case LUA_TSTRING:
					ofLogNotice("ofxLua") << "\t"
						<< (string) lua_typename(L, luabind::type(*iter)) << ": "
						<< iter.key() << " " << (*iter);
					break;
				default:
					ofLogNotice("ofxLua") << "\t"
						<< (string) lua_typename(L, luabind::type(*iter)) << ": "
						<< iter.key();
					break;
			}
				
			if(luabind::type(*iter) == LUA_TTABLE) {
					printTable(luabind::object(*iter), 2);
			}
		}
	}
}
int main(int argc, char * argv[]) {

	int * table;
	int tableRange;

	if(argc == 1)
		tableRange = 10;
	else {
		tableRange = atoi(argv[1]);
		if(tableRange < 1 || tableRange > 10)
			usageAndQuit();
	}	

	table = (int *) malloc(sizeof(int) * (tableRange * tableRange));
	if(table == NULL)
		printf("Memory allocation for table failed.");
	
	fillTable(table, tableRange, (tableRange * tableRange));  

	printTable(table, tableRange, (tableRange * tableRange));

	free(table);

	return 0;	

}
예제 #16
0
Vector adams()
{
  size_t numof_xs = get_numof_xs(h);
  Vector runge_ys = runge();
  Vector adams_ys;
  initVector(&adams_ys, numof_xs);
  for (size_t i = 0; i < adams_acc; ++i)
    append(&adams_ys, runge_ys.values[i]);
  disposeVector(&runge_ys);

  Vector etas;
  initVector(&etas, numof_xs);
  for (size_t i = 0; i < adams_acc; ++i)
    append(&etas, eta(i, adams_ys.values[i]));
  FiniteDiffTable table = createFiniteDiffTable(&etas);

  for (size_t k = 5; k < numof_xs; ++k) {
    double yk = adams_next_yk(adams_ys.values[k - 1], &table);
    append(&adams_ys, yk);
    append(&etas, eta(k, yk));
    disposeFiniteDiffTable(&table);
    table = createFiniteDiffTable(&etas);
  }

  printTable(&table, &adams_ys, stdout);
  disposeVector(&etas);
  disposeFiniteDiffTable(&table);
  return adams_ys;
}
예제 #17
0
void testRetrieve(void) {
  // This depends on testStore being run. because reasons!

  char names[FIELD_SIZE][NAME_LIMIT] = { "name4", "name2", "name3", "name1", };
  FieldType types[FIELD_SIZE][1] = { INTEGER, TEXT, DATE, INTEGER, };
  struct Field* projection = createFieldList(names, NULL, types, 4);
  struct Field* whereField = createField("name1", "2", INTEGER);

  struct Where* compare = createWhere(whereField, EQUAL);
  struct Command* selectCmd = createSelectCommand("table", projection, compare);

  struct Table* results = retrieve(selectCmd);
  printTable(results);
  assert(results->count == 1, "Did not retrieve correct number of records");
  assert(strcmp(results->name, "table") == 0, "Table name was not set in the resultset");

  assert(strcmp(results->tuples[0].fields[0].name, "name1") == 0 , "Problem with resultset");
  assert(strcmp(results->tuples[0].fields[1].name, "name2") == 0 , "Problem with resultset");
  assert(strcmp(results->tuples[0].fields[2].name, "name3") == 0 , "Problem with resultset");
  assert(strcmp(results->tuples[0].fields[3].name, "name4") == 0 , "Problem with resultset");
  assert(results->tuples[0].fields[4].name == 0 , "Problem with resultset"); // make sure null terminated

  assert(strcmp((char*) results->tuples[0].fields[0].value, "2") == 0 , "Problem with resultset");
  assert(strcmp((char*) results->tuples[0].fields[1].value, "value2") == 0 , "Problem with resultset");
  assert(strcmp((char*) results->tuples[0].fields[2].value, "1/1/2015") == 0 , "Problem with resultset");
  assert(strcmp((char*) results->tuples[0].fields[3].value, "3") == 0 , "Problem with resultset");
  assert(results->tuples[0].fields[4].name == 0 , "Problem with resultset");

}
예제 #18
0
QString cm3DebugRegs::printTPIRegisters()
{
    quint32 a;
    TPI_Type tpi;
    QVector<quint32> b(15);
    memset(&tpi,0,sizeof(tpi));

    b[0] = tpi.SSPSR = stl->ReadMemoryWord(a = address(TPI,SSPSR));
    b[1] = tpi.CSPSR = stl->ReadMemoryWord(a = address(TPI,CSPSR));
    b[2] = tpi.ACPR = stl->ReadMemoryWord(a = address(TPI,ACPR));
    b[3] = tpi.SPPR = stl->ReadMemoryWord(a = address(TPI,SPPR));
    b[4] = tpi.FFSR = stl->ReadMemoryWord(a = address(TPI,FFSR));
    b[5] = tpi.FFCR = stl->ReadMemoryWord(a = address(TPI,FFCR));
    b[6] = tpi.FSCR = stl->ReadMemoryWord(a = address(TPI,FSCR));
    b[7] = tpi.TRIGGER = stl->ReadMemoryWord(a = address(TPI,TRIGGER));
    b[8] = tpi.FIFO0 = stl->ReadMemoryWord(a = address(TPI,FIFO0));
    b[9] = tpi.ITATBCTR2= stl->ReadMemoryWord(a = address(TPI,ITATBCTR2));
    b[10] = tpi.FIFO1 = stl->ReadMemoryWord(a = address(TPI,FIFO1));
    b[11] = tpi.ITATBCTR0 = stl->ReadMemoryWord(a = address(TPI,ITATBCTR0));
    b[12] = tpi.ITCTRL = stl->ReadMemoryWord(a = address(TPI,ITCTRL));
    b[13] = tpi.CLAIMSET = stl->ReadMemoryWord(a = address(TPI,CLAIMSET));
    b[14] = tpi.CLAIMCLR = stl->ReadMemoryWord(a = address(TPI,CLAIMCLR));

    static QStringList lst;
    if (lst.isEmpty())
    {
        lst << "SSPSR" << "CSPSR" << "ACPR" << "SPPR" << "FFSR";
        lst << "FFCR" << "FSCR" << "TRIGGER" << "FIFO0" << "ITATBCTR2";
        lst << "FIFO1" << "ITATBCTR0" << "ITCTRL" << "CLAIMSET" << "CLAIMCLR";
    }

    return printTable(&tpi_alt,&tpi,sizeof(tpi),b,lst);
}
예제 #19
0
// processing lines with mismatches 
void extractMismatches(string reads, string baseQuals, int cov, 
                    string transcriptID, string mispos, 
					string ref, int qualThreshold, int coverageThreshold)
{
    int start = 0, end = 0, i = 0;
    baseCounter counter;
    counter["A"] = 0;
    counter["C"] = 0;
    counter["T"] = 0;
    counter["G"] = 0;
    counter["N"] = 0;
    counter["a"] = 0;
    counter["c"] = 0;
    counter["t"] = 0;
    counter["g"] = 0;
    counter["n"] = 0;
	int qual;
	int insertion = 0, deletion = 0, current = 0;
    string strand = "+";
	fixpileup(counter, deletion, insertion, reads, baseQuals, 
            ref, qualThreshold, cov, start, end);
	cov = cov - counter["N"] - counter["n"];
    assert(cov == counter["A"] + counter["C"] + counter["G"] + counter["T"] +
            counter["a"] + counter["c"] + counter["g"] + counter["t"]);
	if (cov > coverageThreshold)
	{
		printTable(transcriptID, mispos, ref, cov,  
					insertion, deletion, counter);
	}
		
}
예제 #20
0
void toggle_on_click(int x, int y)
{
	char   buffer[10];
	int i, j;
	
	int startx = START_X;
	int starty = START_Y;

	if(result == TRUE)
	{
		return;	
	}
	
	for(i=0; i<SIZE+1; i++)
	{
		if(x > (startx - X_INCR/2) && x < (startx + X_INCR/2))
			break; 
		startx += X_INCR;
	}
	if( i >= (SIZE+1) ) return;
	
	for(j=0; j<SIZE+1; j++)
	{
		if(y > (starty - Y_INCR/2) && y < (starty + Y_INCR/2))
			break; 
		starty += Y_INCR;
	}
	if( j >= (SIZE+1) ) return;
	
	i--; j--;
	toggle_neighbours(i, j);
	printTable(SIZE, SIZE);	
}
예제 #21
0
int main()
{
	int x, y, c;
	MEVENT event;
	
	initscr();		
	curs_set(1);
	keypad(stdscr, TRUE);
	mousemask(ALL_MOUSE_EVENTS, NULL);	
	
	initTable();
	printTable(SIZE, SIZE);	
	
	while (result == FALSE) 
	{
		c = wgetch(stdscr);
		if (KEY_MOUSE == c) 
		{
			if (OK == getmouse(&event))
            {
                x = event.x;
                y = event.y;                
                toggle_on_click(x, y);                
			}
		}
	}
	start_color();
	init_pair(1, COLOR_GREEN, COLOR_RED);
	attron(COLOR_PAIR(1));	
	printw("Wow You Win....");
	
	getch();
	endwin();
	return 0;
}
예제 #22
0
void printReport(Table const *table, char const *name)
{
    char const func_char = table->f == my_f ? f_charrep : g_charrep;
    char const *func_str = table->f == my_f ? f_strrep  : g_strrep;
    printf("\n%s for %c(x) = %s on [%Lf, %Lf]\n", name, func_char, func_str, min_x, max_x);
    printTable(table);
    long double const error_coeff = (table->f == my_f ? error_coeff_f : error_coeff_g)(table->xs.size);
    long double const step = (max_x - min_x) / numof_checkpoints;
    long double curr_x = min_x;
    long double max_error = 0.0;
    long double max_upperbound = 0.0;
    Polynomial polynomial;
    makeLagrangePolynomial(&polynomial, table);
    printf("Ln(%c, x) = ", func_char);
    printPolynomial(&polynomial, stdout);
    printf("\n\nNo | x            | %c(x)         | Ln(%c, x)         | error            | A                      | error <= A\n", func_char, func_char);
    printf("---+--------------+--------------+------------------+------------------+------------------------+-----------\n");
    for (size_t i = 1; i <= numof_checkpoints; ++i) {
        long double const x = curr_x + frand() * step;
        long double const y = table->f(x);
        long double const lagrange = lagrangeValue(table, x);

        assert(fabsl(calcValue(&polynomial, x) - lagrange) < 1.e-6);

        long double const error = fabsl(y - lagrange);
        long double const error_upperbound = errorUpperbound(table, x, error_coeff);
        printf("%2zu | %+.9Lf | %+.9Lf | %+16.9Lf | %+16.9Lf | %+22.9Lf | %s\n"
                , i, x, y, lagrange, error, error_upperbound, error <= error_upperbound ? "Yes" : "No");
        curr_x += step;
        max_error = error > max_error ? error : max_error;
        max_upperbound = error_upperbound > max_upperbound ? error_upperbound : max_upperbound;
    }
    printf("\nmax error = %+.9Lf\nmax A     = %+.9Lf\n\n", max_error, max_upperbound);
    disposePolynomial(&polynomial);
}
void 
run() {
  int i = 0; 
  int pageNum; 
  PagePointer cursor; 
  PagePointer cursorPrev; 
  for (; i < INSTRUCTIONSIZE; i++) {
    usleep(256000); 
    pageNum = instructionArray[i] / PAGESIZE; 
    if (isInTable(pageNum) == 1) {
      printf("[命中: address#%d\tin page#%d]\t", instructionArray[i], pageNum); printTable(); 
      /*printf("Hit: address#%d\tin page#%d\t", instructionArray[i], pageNum); printTable(); */
    } else {
      if (getTableLength() < 5) {
        cursor = pageTable->next; 
        cursorPrev = pageTable; 
        while (cursor != NULL) {
          cursor = cursor->next; 
          cursorPrev = cursorPrev->next; 
        }
        cursor = (PagePointer)malloc(sizeof(PageNode)); 
        cursor->num = pageNum; 
        cursor->next = NULL; 
        cursorPrev->next = cursor; 
        printf("[调入: address#%d\tin page#%d]\t", instructionArray[i], pageNum); printTable(); 
        /*printf("In : address#%d\tin page#%d\t", instructionArray[i], pageNum); printTable(); */
      } else {
        PagePointer out = pageTable->next; 
        pageTable->next = out->next; 
        printf("[换出: page#%d]\t", out->num); 
        /*printf("Out: page#%d\t", out->num); */
        out->num = pageNum; 
        out->next = NULL; 
        cursor = pageTable->next; 
        cursorPrev = pageTable; 
        while (cursor != NULL) {
          cursor = cursor->next; 
          cursorPrev = cursorPrev->next; 
        }
        cursorPrev->next = out; 
        printf("[调入: address#%d\tin page#%d]\t", instructionArray[i], pageNum); printTable(); 
        /*printf("In : address#%d\tin page#%d\t", instructionArray[i], pageNum); printTable(); */
      }
    }
  }

}
예제 #24
0
void  RBBIDataWrapper::printData() {
    RBBIDebugPrintf("RBBI Data at %p\n", (void *)fHeader);
    RBBIDebugPrintf("   Version = %d\n", fHeader->fVersion);
    RBBIDebugPrintf("   total length of data  = %d\n", fHeader->fLength);
    RBBIDebugPrintf("   number of character categories = %d\n\n", fHeader->fCatCount);

    printTable("Forward State Transition Table", fForwardTable);
    printTable("Reverse State Transition Table", fReverseTable);
    printTable("Safe Forward State Transition Table", fSafeFwdTable);
    printTable("Safe Reverse State Transition Table", fSafeRevTable);

    RBBIDebugPrintf("\nOrignal Rules source:\n");
    for (int32_t c=0; fRuleSource[c] != 0; c++) {
        RBBIDebugPrintf("%c", fRuleSource[c]);
    }
    RBBIDebugPrintf("\n\n");
}
예제 #25
0
int LuaUtility::showTable(lua_State * L) {
    if (L==nullptr) { return 0; }
    printTable(L,[](const std::string & str) {
        std::cout<<str;
    });
    std::cout.flush();
    return 0;
}
예제 #26
0
int main() {
 int x = enterNumber(32,127);
 int y = enterNumber(x, 127);

 printTable(x,y);

 return(EXIT_SUCCESS);
} 
예제 #27
0
int main(int argc, char * argv[])
{
    Table t;
    t[0] = 12;
    genMultiplyTable(t, N - 1);
    printTable(t, N - 1);
    return 0;
}
// =======================================================================================
// arr :: array of values
// size :: size of array of values
// target :: Any number grater then your threshold, preferably one that in your array (upper bounds )
// threshold :: The number you want to be grater then but cloest too
// ========================================================================================
void smallestSubsetSumGraterThanTreshold (int arr[], int size, int target, int threshold) {
  int i, j ;
  
  //Create table
  int **table ;
	
	// Allocate Memmory
  table = (int **) malloc (sizeof(int*) * (size+1));  
  // Allocate Memmory
  for ( i = 0 ; i <= size ; i ++ ) 
  {
    table[i] = (int *) malloc (sizeof(int) * (target+1));
	  //Set first row true
    table[i][0] = 1 ;
  }
  
  //Zero out table top row
  for ( j = 1 ; j <= target ; j ++ )
	{
		 table[0][j] = 0 ;
	}
	
	//values for min value and it's row
  int minValue = target;
	int firstRow = size;
	
  for ( i = 1 ; i <= size ; i ++ ) 
  {		
    for ( j = 1 ; j <= target ; j ++ )
		{
			// A: if the value above is true set this row's vale to true
			int A =  table[i-1][j];
			// B: if your are before or on the current column max (ex col 7 all the numbers to the right 7+ will be false)
			//    And the table at 
			int B = (arr[i-1] <= j && table[i-1][j-arr[i-1]] );
			//A || B
			table[i][j] =  A || B ;
			
			if ( j > threshold && j < minValue  && table[i][j] )
			{			
				 minValue = j;
				 firstRow = i+1;
			}			
		}
   
  } // End-For
	
  printf("Min Value :: %d\n", minValue );
  printf("Min row :: %d\n", firstRow );
	
	getSubSetSum( table, arr, size, minValue, firstRow );
	
  if ( target < 100 )
  {
		printTable(table, arr, size +1, target +1);
  }
  free (table) ;
}
예제 #29
0
파일: Lexar.c 프로젝트: napzZztar/Courses
int main(){
    char buf[1000];
    FILE *ptr_file;
    typeCount = 7;

    ptr_file =fopen("Lexar.c","r");
    if (!ptr_file)
        return 1;

    while (fgets(buf,1000, ptr_file)!=NULL) {
        trim(buf);
        if((*(buf)=='/' && *(buf+1)=='/') || !strcmp(buf,"\n")){
            printf("%d[%d]. ---- empty line or comment \n", slNo++, lnNo);
        }else  if ((!strcmp(buf, "}\n")) || (!strcmp(trim(buf), "}"))){
            printf("%d[%d]. ____ Closing curly bracket.\n\n", slNo++, lnNo);
        }else{
            if(!incLib(buf)){ // if the statement is not header
                strcpy(temp, buf);
                token = strtok(temp, ";");
                token = strtok(token, " ");

                // Methods and var
                if(!strcmp(token, "struct")){
                    token = strtok(NULL, "{");
                    printf("%d[%d]. Declaring Structure \"%s\" \n",slNo++, lnNo, token);
                    bType[typeCount++] = token;
                }else if(belongsTo(token, bType, typeCount)){
                    strcpy(temp, buf);
                    if(!decMethod(temp)){
                        strcpy(temp, buf);
                        if(decVar(temp)) //if assigned with declaration
                            decnAsgn(buf);
                        //printf("%d[%d]. Are Variable \n", slNo++, lnNo);
                    }
                }else{ 
                    while((*token) == '}') token++;

                    if(belongsTo(token = strtok(token, "("), clYpye, 6)){
                        printf("%d[%d]. Conditional Logic \"%s\"\n", slNo++, lnNo, token);
                    }else if(!strcmp(token, "return")){
                        printf("%d[%d]. End of function \n", slNo++, lnNo);
                    }else{
                        printf("%d[%d]. Function call for \"%s\"\n", slNo++, lnNo, token);
                    }
                }
            }
        }
        lnNo++;
    }

    fclose(ptr_file);

    printf("==============================\n\n\n");

    printTable();
    return 0;
}
예제 #30
0
/*
 Return all the tables data
*/
string Database::printAllTables() {
	string s = "";
	map<string, Table*>::iterator it;
	for (it = tableList.begin(); it != tableList.end(); it++) {
		if (findTable((*it).first) != NULL)
			s += printTable((*it).first);
	}
	return s;
}