int main (void) { struct node *list = NULL, *n; list = create_person (1, "Dave Neary"); n = create_person (2, "Thomas Perl"); add_person (list, n); n = create_person (3, "Alison Chaiken"); add_person (list, n); n = create_person (4, "Andrea Grandi"); add_person (list, n); n = create_person (5, "Kevin Ottens"); add_person (list, n); for (n=list; n; ) { struct node *next = n->next; if (n->p->id % 2 == 0) { delete_person(n); } n = next; } n = create_person (6, "Bob Spencer"); add_person (list, n); write_list (list); return EXIT_SUCCESS; }
GameCanvas::GameCanvas(QWidget *parent) : QWidget(parent) { // make sure game is focused setFocusPolicy(Qt::StrongFocus); // get game logic event loop to work startTimer(1000/60); // load assets this->load_assets(); // initialize animation timer animation_timer = new QTimer(this); connect(animation_timer, SIGNAL(timeout()), this, SLOT(change_frame())); animation_timer->start(animation_speed); app = new game(this); connect(app, SIGNAL(add_person(QPoint,QString)), this, SLOT(add_person(QPoint,QString))); connect(app, SIGNAL(remove_person(QPoint)), this, SLOT(remove_person(QPoint))); }
bool AddressBook::MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input) { #define DO_(EXPRESSION) if (!(EXPRESSION)) goto failure ::google::protobuf::uint32 tag; ::google::protobuf::io::StringOutputStream unknown_fields_string( mutable_unknown_fields()); ::google::protobuf::io::CodedOutputStream unknown_fields_stream( &unknown_fields_string); // @@protoc_insertion_point(parse_start:tutorial.AddressBook) for (;;) { ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127); tag = p.first; if (!p.second) goto handle_unusual; switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // repeated .tutorial.Person person = 1; case 1: { if (tag == 10) { parse_person: DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( input, add_person())); } else { goto handle_unusual; } if (input->ExpectTag(10)) goto parse_person; if (input->ExpectAtEnd()) goto success; break; } default: { handle_unusual: if (tag == 0 || ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) { goto success; } DO_(::google::protobuf::internal::WireFormatLite::SkipField( input, tag, &unknown_fields_stream)); break; } } } success: // @@protoc_insertion_point(parse_success:tutorial.AddressBook) return true; failure: // @@protoc_insertion_point(parse_failure:tutorial.AddressBook) return false; #undef DO_ }
void menu() { char ch[2]; while (1) { printf("1.增加一个联系人\n"); printf("2.删除一个联系人\n"); printf("3.修改一个联系人\n"); printf("4.查找一个联系人\n"); printf("5.显示所有联系人\n"); printf("6.退出\n"); printf("请输入1-6之间的数字:"); scanf("%s",ch); ch[1]='\0'; if (strcmp(ch, "1")==0) { add_person(); } else if (strcmp(ch, "2")==0) { del_person(); } else if (strcmp(ch, "3")==0) { repair_person(); } else if (strcmp(ch, "4")==0) { find_person(); } else if (strcmp(ch, "5")==0) { show_person(); } else if (strcmp(ch, "6")==0) { break; } else { printf("非法输入\n"); } } }
static void output_people( FILE *fp, fields *info, unsigned long refnum, char *tag, char *ctag, char *atag, char *bibtag, int level, int format_opts ) { newstr allpeople; int i, npeople, person, corp, asis; /* primary citation authors */ npeople = 0; for ( i=0; i<info->nfields; ++i ) { if ( level!=-1 && info->level[i]!=level ) continue; person = ( strcasecmp( info->tag[i].data, tag ) == 0 ); corp = ( strcasecmp( info->tag[i].data, ctag ) == 0 ); asis = ( strcasecmp( info->tag[i].data, atag ) == 0 ); if ( person || corp || asis ) { if ( npeople==0 ) newstr_init( &allpeople ); else { if ( format_opts & BIBOUT_WHITESPACE ) newstr_strcat(&allpeople,"\n\t\tand "); else newstr_strcat( &allpeople, "\nand " ); } if ( corp ) { newstr_addchar( &allpeople, '{' ); newstr_strcat( &allpeople, info->data[i].data ); newstr_addchar( &allpeople, '}' ); } else if ( asis ) { newstr_addchar( &allpeople, '{' ); newstr_strcat( &allpeople, info->data[i].data ); newstr_addchar( &allpeople, '}' ); } else add_person( &allpeople, info->data[i].data ); fields_setused( info, i ); npeople++; } } if ( npeople ) { output_element( fp, bibtag, allpeople.data, format_opts ); newstr_free( &allpeople ); } }
int main(int argc, char *argv[]) { char word[20]; //primul cuvant de pe fiecare linie din fisierul de intrare FILE *f = fopen(argv[1], "r"); int N; fscanf(f, "%d\n", &N); struct window *windows = new struct window[N]; //vector de ghisee Queue<person> *q = new Queue<person>[N]; //vector de cozii Stack<int> *s = new Stack<int>[N]; //vector de stive struct array arrayWindows; //retine cate ghisee au fost deschise si ID-urile arrayWindows.nrWindows = 0; arrayWindows.A = new int[N]; //citirea si interpretarea fisierului de input while(fscanf(f, "%s", word) == 1) { if(strcmp(word, "OPEN_WINDOW") == 0) { int window_id, weight_min, weight_max, q_, k; fscanf(f, "%d%d%d%d%d", &window_id, &weight_min, &weight_max, &q_, &k); open_window(windows, &arrayWindows, q, s, window_id, weight_min, weight_max, q_, k); } else if(strcmp(word, "ADD_PERSON") == 0) { int personal_id, package_weight, window_id; fscanf(f, "%d%d%d", &personal_id, &package_weight, &window_id); add_person(q, personal_id, package_weight, window_id); } else if(strcmp(word, "PROCESS") == 0) { int window_id, n_people; fscanf(f, "%d%d", &window_id, &n_people); process(windows, arrayWindows, q, s, window_id, n_people); } else if(strcmp(word, "PROCESS_ALL") == 0) { int window_id; fscanf(f, "%d", &window_id); processAll(windows, arrayWindows, q, s, window_id); } else if(strcmp(word, "PRINT_QUEUES") == 0) printQueues(q, arrayWindows); else if(strcmp(word, "PRINT_STACKS") == 0) printStacks(s, arrayWindows); else if(strcmp(word, "FLUSH_STACKS") == 0) flushStacks(s, arrayWindows); } fclose(f); return 0; }