本文整理汇总了C++中printTable函数的典型用法代码示例。如果您正苦于以下问题:C++ printTable函数的具体用法?C++ printTable怎么用?C++ printTable使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了printTable函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
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: while
// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
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: main
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: main
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: printAllTables
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]);
}
}
示例6: weights
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: printTables
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: main
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: main
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: setup
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: moveSpace
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: lua_type
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: main
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;
}
示例14: adams
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;
}
示例15: testRetrieve
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");
}