本文整理汇总了C++中print_table函数的典型用法代码示例。如果您正苦于以下问题:C++ print_table函数的具体用法?C++ print_table怎么用?C++ print_table使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了print_table函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: expand_table
// dynamically expand hash table
void expand_table(hash_table *h)
{
int i, index, new_size;
new_size = next_prime(h->capacity * 2 + 1);
// create new, expanded hash table
hash_table *new_table = create_table(new_size);
printf("Hash table before expansion to size %d:\n", new_size);
print_table(h);
// rehash elements from the old table into the new table
for (i = 0; i < h->capacity; i++)
{
if (h->table[i] != NULL)
{
index = get_pos(new_table, *h->table[i]);
new_table->table[index] = h->table[i];
new_table->size++;
}
}
free(h->table);
h->table = new_table->table;
h->size = new_table->size;
h->capacity = new_table->capacity;
free(new_table);
printf("Hash table after expansion:\n");
print_table(h);
}
示例2: print_state
void print_state(state_t *state) {
print_table(state->table1);
if (state->table2) {
print_table(state->table2);
print_edge(state);
}
}
示例3: main
int main(int argc, char* argv[])
{
HashTable *ht;
char *val;
ht = hash_init_table();
hash_put(ht, "apple", "red");
hash_put(ht, "lemon", "yellow");
hash_put(ht, "orange", "orange");
print_table(ht);
hash_put(ht, "orange", "green");
print_table(ht);
hash_delete(ht, "orange");
print_table(ht);
val = hash_get(ht, "apple");
val = hash_get(ht, "lemon");
val = hash_get(ht, "orange");
hash_uninit_table(ht);
return 0;
}
示例4: __attribute__
static void __attribute__ ((__noreturn__)) usage(int exitcode)
{
FILE *out = exitcode == EXIT_SUCCESS ? stdout : stderr;
fputs(USAGE_HEADER, out);
fprintf(out, _(" %s [options] <ldisc> <device>\n"), program_invocation_short_name);
fputs(USAGE_OPTIONS, out);
fputs(_(" -d, --debug print verbose messages to stderr\n"), out);
fputs(_(" -s, --speed <value> set serial line speed\n"), out);
fputs(_(" -7, --sevenbits set character size to 7 bits\n"), out);
fputs(_(" -8, --eightbits set character size to 8 bits\n"), out);
fputs(_(" -n, --noparity set parity to none\n"), out);
fputs(_(" -e, --evenparity set parity to even\n"), out);
fputs(_(" -o, --oddparity set parity to odd\n"), out);
fputs(_(" -1, --onestopbit set stop bits to one\n"), out);
fputs(_(" -2, --twostopbits set stop bits to two\n"), out);
fputs(_(" -i, --iflag [-]<iflag> set input mode flag\n"), out);
fputs(USAGE_SEPARATOR, out);
fputs(USAGE_HELP, out);
fputs(USAGE_VERSION, out);
fputs(_("\nKnown <ldisc> names:\n"), out);
print_table(out, ld_discs);
fputs(_("\nKnown <iflag> names:\n"), out);
print_table(out, ld_iflags);
fputc('\n', out);
fprintf(out, USAGE_MAN_TAIL("ldattach(8)"));
exit(exitcode);
}
示例5: main
int main()
{
struct Table* tbl = create_table();
insert(tbl,"value0",0);
insert(tbl,"value1",1);
insert(tbl,"value2",2);
print_table(tbl);
printf("Removing value1\n");
{
int val = erase(tbl,"value1");
printf("value1 had value %d\n",val);
}
print_table(tbl);
{
int val = find(tbl,"value2");
printf("value2 has value %d\n",val);
val = find(tbl,"valuex");
if (val == -99999)
printf("can't find valuex\n");
val = erase(tbl,"valuex");
if (val == -99999)
printf("can't erase valuex\n");
}
destroy(tbl);
}
示例6: main
int main()
{
int loop = 1;
int input = -1;
while(loop) {
printf("Virtual memory to Main memory mapping:\n");
printf("--------------------------------------\n");
printf("1) Set parameters\n");
printf("2) Map virtual address\n");
printf("3) Print page table\n");
printf("4) Quit\n");
printf("\n");
printf("Enter selection: ");
scanf("%d", &input);
switch(input) {
case 1:
setparameters();
break;
case 2:
map_addr();
break;
case 3:
print_table();
break;
case 4:
loop = 0;
break;
default:
printf("Invalid selection.");
}
printf("\n\n");
}
return 0;
}
示例7: lookup_and_combine_restaurant_tables
void RestaurantPrinter::print_restaurants_that_accept(string payment_type) {
Table restaurants = database_->query("placeID", "PaymentType", "payment = '" + payment_type + "'");
Table results = lookup_and_combine_restaurant_tables(restaurants, 0);
print_table("Restaurants With Payment Type: " + payment_type, results);
}
示例8: regfileCheckCallTf
static PLI_INT32 regfileCheckCallTf()
{
s_vpi_value value;
static int counter = 0; // countes the clock cycles
int passed = 0;
update_time();
value.format = vpiIntVal;
for (int i = 0; i < ARGS_NR; ++i) {
vpi_get_value(args[i].handle, &value);
args[i].value = value.value.integer;
}
// compare w_data with r_data
if (args[4].value == args[5].value
&& args[4].value == args[6].value
&& args[0].value != 0)
passed = 1;
else if (args[0].value != 0)
passed = -1;
else
passed = 0;
print_table(args, ARGS_NR, &g_time, &counter, &passed);
++counter;
return 0;
}
示例9: restaurants_with_min_average
void RestaurantPrinter::print_restaurants_with_at_least_average_rating(float minimum_rating) {
Table restaurants = database_->query("*", "Locations", "");
// create a table with the same structure as Ratings
Table restaurants_with_min_average(database_->query("*", "Ratings", "").attributes());
for_each_record(restaurants, [&] (Record &record) {
Table ratings = database_->query("*", "Ratings", "placeID = '" + record.retrieve(0) + "'");
float average = ratings.sum("rating") / ratings.count("rating");
// if it meets the minimum we want to insert the FIRST instance of the rating
// into the table so that the placeID is present once, and can be passed to
// lookup_and_combine_restaurant_tables()
if (average > minimum_rating) {
TableIterator it(ratings);
it.first();
Record record = it.getRecord();
vector<string> attributes;
for (int i = 0; i < record.size(); i++) {
attributes.push_back(record.retrieve(i));
}
restaurants_with_min_average.insert(attributes);
}
});
print_table("Restaurants With Minimum Average Rating", lookup_and_combine_restaurant_tables(restaurants_with_min_average, 1));
}
示例10: main
int main() {
CassFuture* connect_future = NULL;
CassCluster* cluster = cass_cluster_new();
CassSession* session = cass_session_new();
cass_cluster_set_contact_points(cluster, "127.0.0.1");
connect_future = cass_session_connect(session, cluster);
if (cass_future_error_code(connect_future) == CASS_OK) {
CassFuture* close_future = NULL;
execute_query(session,
"CREATE KEYSPACE examples WITH replication = { \
'class': 'SimpleStrategy', 'replication_factor': '3' };");
print_keyspace(session, "examples");
execute_query(session,
"CREATE TABLE examples.schema_meta (key text, \
value bigint, \
PRIMARY KEY (key));");
print_table(session, "examples", "schema_meta");
/* Close the session */
close_future = cass_session_close(session);
cass_future_wait(close_future);
cass_future_free(close_future);
} else {
示例11: print_table
void CashboxWindow::delete_selected_table_row()
{
int rowNum;
QString hotkeyName;
QList<QTableWidgetItem*> row = this->product_table->selectedItems();
if(row.count()==4) {
for(int i = 0; i < row.count();i++) {
//Only delete rows..
if(i == 0) {
rowNum = row.at(i)->row();
hotkeyName = row.at(1)->text();
}
if(rowNum == row.at(i)->row()) {
row.at(i)->~QTableWidgetItem();
}
if(i == 3) {
this->totalPrice -= row.at(i)->text().toDouble();
this->lbTotalPrice->setText(QString::number(this->totalPrice)+"€");
}
}
}
//Set Hotkey-Count = 0
for(int i = 0; i < MyHotkeys.count(); i++) {
//Set count 0
if(MyHotkeys.at(i)->getProductname()==hotkeyName) {
MyHotkeys.at(i)->setCount(0);
}
}
print_table();
}
示例12: main
int main(void){
int i,j;
char tc;
int find;
while(1){
for(i=0;i<8;i++){//读棋盘
scanf("%s",ch[i]);
if(ch[i][0]=='-'){
return 0;
}
}
find=0;
for(i=0;i<8;i++){//找起点
for(j=0;j<8;j++){
tc=ch[i][j];
if(tc=='<'||tc=='>'||tc=='^'||tc=='v'){
r=i;
c=j;
find=1;
if(tc=='^'){
direction=0;
break;
}
if(tc=='>'){
direction=1;
break;
}
if(tc=='v'){
direction=2;
break;
}
if(tc=='<'){
direction=3;
break;
}
}
}
if(find){
break;
}
}
while(1){//读scripts
scanf("%s",command);
if(command[0]=='#'){
break;
}
if(command[0]=='m'){
scanf("%d",&step);
moveOn();
}else{
scanf("%s",dc);
turn();
}
}
print_table();
}
return 0;
}
示例13: print_stack
// Print all elements of a stack
void print_stack(struct stack *top){
while(top){
print_table(top->table);
printf("%d\n",top->step);
top=top->next;
}
}
示例14: main
int main() {
int n, i, v;
char verb[4], prep[4];
block *blocks[MAX];
block *a, *b;
for(i = 0; i < MAX; i++)
table[i] = blocks[i] = NULL;
/* Read number of blocks `n`. */
Si(n);
/* Initialize world with `n` blocks. */
for(i = 0; i < n; i++) {
table[i] = blocks[i] = (block *) malloc(sizeof(block));
blocks[i]->above = NULL;
blocks[i]->below = NULL;
blocks[i]->table_loc = i;
blocks[i]->value = i;
}
while(1) {
/* Read the verb. */
Ss(verb);
/* Exit when verb is quit. */
if(verb[0] == 'q') break;
/* Read the object. */
Si(v);
a = blocks[v];
/* Read the preposition. */
Ss(prep);
/* Read the complement. */
Si(v);
b = blocks[v];
/* Ignore action if it is illegal. */
if(a->table_loc == b->table_loc) continue;
/* When verb is `move`, put back that are above the object `a`. */
if(verb[0] == 'm') put_back(a);
/* When preposition is `onto`, put back the blocks that are above the complement `b`. */
if(prep[1] == 'n') put_back(b);
/* Pile object `a` over complement `b`. */
stack(a, b);
}
print_table(n);
for(i = 0; i < n; i++)
free(blocks[i]);
return 0;
}
示例15: main
int main (void)
{
char s[21], /* a temp word variable */
table[200][21]; /* the table of words */
int ns[200]; /* array of occurences */
int n; /* count variable */
for(n=0;n<199;n++) ns[n]=1; /* set up the array */
n=0;
do
{
get_word(s); /* input a word from the inout */
if (!strcmp(s,"* no more *"))
{
/* If it is the end of the file : */
print_table(sort(table,ns,n),n,ns);
return(0);
}
convert_word(s); /* make the word loower case */
if (!lookup(s,table,n,ns))
{
/* word is not in the table yet */
insert_word(s,table,n);
n++;
}
} while (1);
/* wont quit until the end of file is reached */
}