本文整理汇总了C++中print_table函数的典型用法代码示例。如果您正苦于以下问题:C++ print_table函数的具体用法?C++ print_table怎么用?C++ print_table使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了print_table函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);
}
开发者ID:ShowLove,项目名称:perfectMySkills,代码行数:36,代码来源:hash_table_int_null.c
示例2: print_state
void print_state(state_t *state) {
print_table(state->table1);
if (state->table2) {
print_table(state->table2);
print_edge(state);
}
}
开发者ID:gredman,项目名称:yumbo,代码行数:7,代码来源:dot.c
示例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;
}
开发者ID:alphaKAI,项目名称:kaios,代码行数:28,代码来源:hash.c
示例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);
}
开发者ID:bdwalton,项目名称:util-linux,代码行数:30,代码来源:ldattach.c
示例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);
}
开发者ID:AndrewFrauens,项目名称:stroustrup_ppp,代码行数:25,代码来源:chapter27_ex12.c
示例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;
}
开发者ID:stefaneng,项目名称:comp-arch,代码行数:34,代码来源:asmt4_eng.c
示例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);
}
开发者ID:tmandry,项目名称:db-team15-test,代码行数:7,代码来源:restaurant_printer.cpp
示例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;
}
开发者ID:afi-lambda,项目名称:riscymips,代码行数:29,代码来源:regfile_test_vpi.c
示例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));
}
开发者ID:tmandry,项目名称:db-team15-test,代码行数:26,代码来源:restaurant_printer.cpp
示例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 {
开发者ID:Ilceren,项目名称:cpp-driver,代码行数:29,代码来源:schema_meta.c
示例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();
}
开发者ID:KeineMemme,项目名称:Cashbox,代码行数:32,代码来源:cashboxwindow.cpp
示例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;
}
开发者ID:kensou97,项目名称:algorithms,代码行数:60,代码来源:poj3344.c
示例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;
}
}
开发者ID:letrungkien211,项目名称:SoftwareII,代码行数:8,代码来源:main.c
示例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;
}
开发者ID:mrrusof,项目名称:algorithms,代码行数:60,代码来源:main.c
示例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 */
}
开发者ID:pete0877,项目名称:wpi,代码行数:30,代码来源:hw4.c
示例16: rip_incoming
void rip_incoming(ssize_t n)
/* Use a RIP packet to add to the router table. (RIP packets are really for
* between routers, but often it is the only information around.)
*/
{
udp_io_hdr_t *udp_io_hdr;
u32_t default_dist;
i32_t pref;
routeinfo_t *routeinfo;
struct routedata *data, *end;
/* We don't care about RIP packets when there are router adverts. */
if (now + MaxAdvertisementInterval < router_advert_valid) return;
udp_io_hdr= (udp_io_hdr_t *) rip_buf;
if (udp_io_hdr->uih_data_len != n - sizeof(*udp_io_hdr)) {
if (debug) printf("Bad sized route packet (discarded)\n");
return;
}
routeinfo= (routeinfo_t *) (rip_buf + sizeof(*udp_io_hdr)
+ udp_io_hdr->uih_ip_opt_len);
if (routeinfo->command != RIP_REPLY) {
if (debug) {
printf("RIP-%d packet command %d ignored\n",
routeinfo->version, routeinfo->command);
}
return;
}
/* Look for a default route, the route to the gateway. */
end= (struct routedata *) (rip_buf + n);
default_dist= (u32_t) -1;
for (data= routeinfo->data; data < end; data++) {
if (ntohs(data->family) != AF_INET || data->ip_addr != 0)
continue;
default_dist= ntohl(data->metric);
if (default_dist >= 256) {
if (debug) {
printf("Strange metric %lu\n",
(unsigned long) default_dist);
}
}
}
pref= default_dist >= 256 ? 1 : 512 - default_dist;
pref+= priority_offset;
/* Add the gateway to the table with the calculated preference. */
add_gateway(udp_io_hdr->uih_src_addr, pref);
if (debug) {
printf("Routing table after RIP-%d packet from %s:\n",
routeinfo->version,
addr2name(udp_io_hdr->uih_src_addr));
print_table();
}
/* Start advertizing. */
if (next_advert == NEVER) next_advert= IMMEDIATELY;
}
开发者ID:AjeyBohare,项目名称:minix,代码行数:60,代码来源:irdpd.c
示例17: main
int main(int argv, char **argc)
{
FILE *input_file;
char *filename = argc[1];
struct dev_set_c *set_info;
struct table **table_array; /* table_bdev[bdev_nr]*/
error_t error_msg;
if ( !(input_file = fopen(filename, "r")) ) {
printf("No such file %s\n", filename);
return -1;
}
get_devs_info(argv, argc, &set_info);
alloc_table_array(set_info, &table_array);
init_table(set_info, table_array);
if ( map(input_file, set_info, table_array) < 0) {
printf("[ERROR] : can not do mapping workload to your device\n");
return -1;
}
print_devs_info(set_info);
print_table(set_info, table_array);
//ratio = find_scale_ratio(set_info, &last_blk_info);
//printf("%lf %u %llu %u %x\n", one_req_info.time, one_req_info.devno, one_req_info.blkno, one_req_info.bcount, one_req_info.is_read);
return 0;
}
开发者ID:Lim-Kwang-Hyun,项目名称:trace_analyzer,代码行数:35,代码来源:main.c
示例18: user_interface
void user_interface( ){
// window dimensions
int maxX, maxY, cursor = 0;
// iterate until its time to exit
while( true ){
// get the window size
maxX = getmaxx(stdscr);
maxY = getmaxy(stdscr);
// clear the screen
clear();
// print the header
print_header("Task Listing", maxX);
// print the table
print_table( maxX, maxY, 4 , cursor);
// print the footer
print_footer( GUI, maxX, maxY );
// get the input
int arg = getch();
// exit the program
if( arg == 27 )
break;
// create a new task
else if( arg == 'c' || arg == 'C' ){
create_task( );
}
// view the selected task
else if( arg == 'V' || arg == 'v' ){
view_task( );
}
// move the cursor up
else if( arg == KEY_UP ){
cursor--;
if( cursor < 0 ){
cursor = options.tasks.size()-1;
}
}
// move the cursor down
else if( arg == KEY_DOWN ){
cursor++;
if( cursor >= options.tasks.size() )
cursor = 0;
}
}
}
开发者ID:alicankrc,项目名称:Code_Sandbox,代码行数:59,代码来源:UI.cpp
示例19: main
int main() {
printf("table.c tests\n");
printf("table_dimensions = %d, %d\n", table_dims.x, table_dims.y);
init_table();
printf("table_dimensions = %d, %d\n", table_dims.x, table_dims.y);
print_table();
printf("expand_table_cols()\n");
expand_table_cols();
printf("table_dimensions = %d, %d\n", table_dims.x, table_dims.y);
print_table();
printf("expand_table_rows()\n");
expand_table_rows();
printf("table_dimensions = %d, %d\n", table_dims.x, table_dims.y);
print_table();
}
开发者ID:Fresne,项目名称:i3-1,代码行数:17,代码来源:test_table.c
示例20: parse_args
/*
* parse_args Parse the arguments from the command line into the fields
* structure. Inputs: argc, argv Output: the table of name/value pairs for the
* object being created is filled in with values from the arg list. Returns 0
* Success 1 if error For every name/value pair in the arg list, search for
* the name in the field_table (all possible argument names) and fill the
* value in the table. Note: An error message is printed for every argument
* that is not in the fields table. All arguments are parsed.
*/
int parse_args(
int argc,
char **argv,
int index,
struct object_field *tbl)
{
int i,
n,
err = 0;
char *cur,
*name,
*value;
int name_len;
memset(parse_errstr, 0, sizeof(parse_errstr));
// for every argument in the list, update the table with the new value
// first arg is program name and second is object type. The remainder are
// object fields
for (i = index; i < argc; i++)
{
cur = argv[i];
name = cur;
value = strchr(cur, '=');
if (value == NULL)
{
if (err != 0) // not first error, add comma
strcat(parse_errstr, ", ");
strcat(parse_errstr, cur);
err = 1;
}
else
{ // find the right place in the table to put
// the value
name_len = value - name;
if ((n = fieldInTable(name, name_len, tbl)) >= 0)
tbl[n].value = stripws(++value);
else
{
if (err != 0) // not first error, add comma
strcat(parse_errstr, ", ");
strcat(parse_errstr, name);
err = 1;
}
}
}
// done
#ifdef DEBUG
if (err == 0)
print_table(tbl);
#endif
return err;
}
开发者ID:dseomn,项目名称:rpstir,代码行数:65,代码来源:create_object.c
注:本文中的print_table函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论