int main() { FILE *entrada, *aprovados, *reprovados; Aluno aluno, aux; int i, j, n; entrada = fopen("alunos.txt","r+b"); if (entrada == NULL) { entrada = fopen("alunos.txt","wb"); printf("Nao foi possivel ser o arquivo"); exit(1); } menu(); while(scanf("%d",&n), n) { switch(n) { case 1: printf("\n"); printf("Digite o o numero, nome, curso e nota do aluno(a):\n"); scanf("%d %s %s %d", &aluno.numero, aluno.nome, aluno.curso, &aluno.nota); fseek(entrada, 0, SEEK_END); if(fwrite(&aluno, sizeof(aluno), 1, entrada)) printf("O Aluno(a) foi cadastrado com sucesso\n\n"); break; case 2: printf("\n"); fseek(entrada, 0, SEEK_SET); while(fread(&aluno, sizeof(aluno), 1, entrada)) { printf("%d\n",aluno.numero); printf("%s\n",aluno.nome); printf("%s\n",aluno.curso); printf("%d\n",aluno.nota); printf("\n"); } break; case 3: printf("\n"); aprovados = fopen("aprovados.txt", "wt"); fseek(entrada, 0, SEEK_SET); while(fread(&aluno, sizeof(aluno), 1, entrada)) { if (aluno.nota >= 7) { printf("%d\n",aluno.numero); printf("%s\n",aluno.nome); printf("%s\n",aluno.curso); printf("%d\n",aluno.nota); printf("\n"); fprintf(aprovados, "%d\n",aluno.numero); fprintf(aprovados, "%s\n",aluno.nome); fprintf(aprovados, "%s\n",aluno.curso); fprintf(aprovados, "%d\n",aluno.nota); fprintf(aprovados, "\n"); } } fclose(aprovados); break; case 4: printf("\n"); reprovados = fopen("reprovados.txt", "wt"); fseek(entrada, 0, SEEK_SET); while(fread(&aluno, sizeof(aluno), 1, entrada)) { if (aluno.nota < 7) { printf("%d\n",aluno.numero); printf("%s\n",aluno.nome); printf("%s\n",aluno.curso); printf("%d\n",aluno.nota); printf("\n"); fprintf(reprovados, "%d\n",aluno.numero); fprintf(reprovados, "%s\n",aluno.nome); fprintf(reprovados, "%s\n",aluno.curso); fprintf(reprovados, "%d\n",aluno.nota); fprintf(reprovados, "\n"); } } fclose(reprovados); break; } menu(); } fclose(entrada); system("pause"); return 0; }
int main(int argc, char* argv[]) { int choice; // Variable for the choice in menu Rational left, // Rational variable for the first fraction right, // Rational variable for the second fration result; // Rational variable for the result if(argc != 2) { cout << "You MUST enter a name via the prompt (IE \"jbprog1 Josh\")"; exit(0); } // Keep us in the program unless we exit do { cout << "Hello " << argv[1] << endl; choice = menu(); // Input two fractions if(choice == 1) { cout << "First fraction:" << endl;; left.inp_single(); cout << "Second fraction:" << endl; right.inp_single(); if(left == right) cout << "\nThe two fractions entered are equal" << endl << endl; else if(left > right) cout << "The first fraction is greater than the second" << endl << endl; else if(left < right) cout << "The first fraction is less than the second" << endl << endl; } // Add and display result else if(choice == 2) { result = left + right; cout << left << " + " << right << " = " << result; //left.disp_oneFrac(); //cout << " + "; //right.disp_oneFrac(); //cout << " = "; //result.disp_oneFrac(); cout << " or "; result.disp_floatFrac(); cout << endl << endl; } // Subtract and display result else if(choice == 3) { // result = left.sub_fractions(right); result = left - right; cout << left << " - " << right << " = " << result; //left.disp_oneFrac(); //cout << " - "; //right.disp_oneFrac(); //cout << " = "; //result.disp_oneFrac(); cout << " or "; result.disp_floatFrac(); cout << endl << endl; } // Multiply and display result else if(choice == 4) { //result = left.mul_fractions(right); result = left * right; cout << left << " * " << right << " = " << result; //left.disp_oneFrac(); //cout << " * "; //right.disp_oneFrac(); //cout << " = "; //result.disp_oneFrac(); cout << " or "; result.disp_floatFrac(); cout << endl << endl; } // Divide and display result else if(choice == 5) { //result = left.div_fractions(right); result = left / right; cout << left << " / " << right << " = " << result; //left.disp_oneFrac(); //cout << " / "; //right.disp_oneFrac(); //cout << " = "; //result.disp_oneFrac(); cout << " or "; result.disp_floatFrac(); cout << endl << endl; } // Quit else if(choice == 6) cout << "Quitting" << endl; else cout << "Invalid choice, try again" << endl; } while(choice != 6); return 0; }
void main() { textbackground(14); show_mouse(); menu(); }
int main() { char choice; int noOrders = 0; iOrder* order[MAXORDERS]; Prefix prefix("prefixRanges.txt"); std::cout << "Bookstore Order Processor\n" << "=========================\n"; // process user input do { choice = menu(std::cin); std::cout << std::endl; switch (choice) { case 'P': { EAN ean; if (ean.read(std::cin, prefix)) { int index = -1, created = false; for (int i = 0; i < noOrders && index == -1; i++) { if (ean == order[i]->getEAN()) { index = i; } } if (index == -1) { if (noOrders < MAXORDERS) { index = noOrders; order[noOrders++] = new Order(ean); created = true; } else { std::cerr << "No space for more orders!" << std::endl; } } if (!order[index]->add(std::cin) && created) { delete order[--noOrders]; } } } break; case 'S': { EAN ean; if (ean.read(std::cin, prefix)) { int index = -1, created = false; for (int i = 0; i < noOrders && index == -1; i++) { if (ean == order[i]->getEAN()) { index = i; } } if (index == -1) { if (noOrders < MAXORDERS) { index = noOrders; order[noOrders++] = new SpecialOrder(ean, ""); created = true; } else { std::cerr << "No space for more orders!" << std::endl; } } if (!order[index]->add(std::cin) && created) { delete order[--noOrders]; } } } break; case 'A': { EAN ean; if (ean.read(std::cin, prefix)) { int index = -1; for (int i = 0; i < noOrders && index == -1; i++) { if (ean == order[i]->getEAN()) { index = i; } } if (index != -1) { order[index]->add(1); } else { std::cerr << "No order for " << ean << " found!" << std::endl; } } } break; case 'D': { EAN ean; if (ean.read(std::cin, prefix)) { int index = -1; for (int i = 0; i < noOrders && index == -1; i++) { if (ean == order[i]->getEAN()) { index = i; } } if (index != -1) { order[index]->receive(std::cin); } else { std::cerr << "No order for " << ean << " found!" << std::endl; } } } break; case 'F': { char s; if (style(std::cin, s)) for (int i = 0; i < noOrders; i++) { order[i]->getEAN().style(s); } } break; case 'V': std::cout << " EAN Ordered Delivered Instructions\n"; std::cout << "--------------------------------------------------\n"; for (int i = 0; i < noOrders; i++) { std::cout << *order[i] << std::endl; } break; } } while (choice != 'Q'); std::cout << "\nSigning off ... " << std::endl; // deallocate order memory for (int i = 0; i < noOrders; i++) { delete order[i]; } }
int main(int argc, char *argv[]) { g_mem = load_into_mem(-1, &qt_games); menu(); return 0; }
int main(){ student_t *head, *newStudent,*temp; int age,major; float gpa; char * name, *name1, cr; char *msg; int i; int answer,data; head = NULL; printf("You are now entering the student zone!\n"); answer = menu(); while(answer != 7){ switch (answer) { case 1: printf("enter age:\n"); scanf("%d%c",&age,&cr); printf("enter gpa:\n"); scanf("%f%c",&gpa,&cr); printf("enter major:\n"); scanf("%d%c",&major,&cr); printf("enter name:\n"); name = getline(); //printf("length: %d\n",strlen(name)); newStudent = createStudent(age, name,major,gpa); break; case 2: insertStudent(&head,newStudent); break; case 3: printf("enter student name to delete\n"); name1 = getline(); deleteStudent(&head,name1); free(name1); break; case 4: printf("enter student name to investigate\n"); name1 = getline(); data = dataMenu(); switch (data) { case 1: temp = findStudent(head, name1); if(temp == NULL){ printf("Student %s not found \n",name1); break; } age = getAge( temp); printf("The age of %s, is %d\n",name1,age); break; case 2: temp = findStudent(head, name1); if(temp == NULL){ printf("Student %s not found \n",name1); break; } gpa = getGpa( temp); printf("The gpa of %s, is %f\n",name1,gpa); break; case 3: temp = findStudent(head, name1); if(temp == NULL){ printf("Student %s not found \n",name1); break; } major = getMajor( temp); printf("The gpa of %s, is %d\n",name1,major); break; default: break; } break; case 5: temp = head; while(temp != NULL){ msg = toString( temp); printf("%s\n",msg); temp = temp->link; } break; case 6: insertStudentRear(&head,newStudent); break; default: break; } answer = menu(); } printf("BYE\n"); return(0); }
//====================================================================== int main(){ int system_call_return_value; system_call_return_value = system("clear"); system_call_return_value = system("clear"); //================================================================== // star camera //================================================================== //============================================================== // intrinsic paramters for star camera //============================================================== intrinsic_camera_parameter parameters_for_star_camera; /* parameters_for_star_camera.set_names( "ueye 5MPx CMOS", "Carl Zeiss Flektogon F2.4 / f35mm"); parameters_for_star_camera.set_FoV_to_pixel_mapping(3.34375E-3); */ parameters_for_star_camera.set_names( "ueye 5MPx CMOS","Flektogon F1.8 / f50mm"); parameters_for_star_camera.set_FoV_to_pixel_mapping(0.002427534); parameters_for_star_camera. set_coefficients_for_radiometric_correction_plane( -1.2185, 1.2021, 0.99303 ); ueye_camera star_camera(13,parameters_for_star_camera); //================================================================== // reflector camera //================================================================== //============================================================== // intrinsic paramters for reflector camera //============================================================== intrinsic_camera_parameter parameters_for_reflector_camera; parameters_for_reflector_camera.set_names( "Thor Labs 1.3MPx CCD", "M12 the imageing source F2.0 / f4mm" ); parameters_for_reflector_camera. set_coefficients_for_radiometric_correction_plane( -1.1527, 1.0283, -0.18637 ); ueye_camera reflector_camera(42,parameters_for_reflector_camera); star_camera.display_camera_information(); reflector_camera.display_camera_information(); //================================================================== // hanldes //================================================================== sccan_point_pair_handler sccan_handle; sccan_handle.set_cameras(&star_camera,&reflector_camera); //sccan_handle.acquire_sccan_points(5); snapshot snap; snap.add_camera(&star_camera); snap.add_camera(&reflector_camera); reflector reflector_instance(&reflector_camera); quick_align quick(&reflector_instance,&sccan_handle); //tester star_recognition_test_environment test_environment; sccan_point_analysis analysis( &sccan_handle,&reflector_instance//,&star_camera ); verbosity_handler verbosity_interaction( &global_time_stamp_manager_instance, &star_camera, &reflector_camera, &reflector_instance, &snap, &sccan_handle, &quick, &analysis ); main_menu menu( &snap, &reflector_instance, &sccan_handle, &quick, &analysis, &verbosity_interaction, &star_camera, &reflector_camera, &test_environment); menu.interaction(); return 0; }
int main() { int choice; //用户选择 int num; //学号 //初始化学生信息结构体变量 if (!init_student_info_list()) { if (!student_list) { //释放内存 free(student_list); } return 0; } printf("***************************\n"); printf("* 学生信息管理系统 *\n"); printf("***************************\n"); printf("---------------------------\n"); if (read_file()) { printf("初始化成功,欢迎使用!\n"); } else { printf("初始化失败,请检查后重启程序!\n"); getchar(); return 0; } printf("---------------------------\n"); printf("-----------菜单------------\n"); printf("---------------------------\n"); menu(); //打印菜单 while (TRUE) { printf("请选择操作:"); scanf("%d", &choice); switch (choice) { case 1: if (student_list_empty()) { printf("学生信息表为空,请先添加学生信息!\n"); } else { display_student_info(); } break; case 2: if (add_student_info()) { printf("添加学生信息成功!\n"); } else { printf("添加学生信息失败!\n"); getchar(); return 0; } break; case 3: if (student_list_empty()) { printf("学生信息表为空,请先添加学生信息!\n"); } else { printf("请输入要删除学生信息记录的学号:"); scanf("%d", &num); if (delete_student_info(num)) { printf("学号为%d的学生记录删除成功!\n", num); } else { printf("删除失败!\n"); } } break; case 4: if (student_list_empty()) { printf("学生信息表为空,请先添加学生信息!\n"); } else { printf("请输入要修改学生信息记录的学号:"); scanf("%d", &num); if (modify_student_info(num)) printf("学号为%d的学生记录修改成功!\n", num); else printf("修改失败!\n"); } break; case 5: if (student_list_empty()) { printf("学生信息表为空,请先添加学生信息!\n"); } else { if (save_file()) { printf("保存学生信息成功!\n"); } else { printf("保存学生信息失败!\n"); } } break; case 6: printf("请输入要查找学生信息记录的学号:"); scanf("%d", &num); student_info *pstu = search_student_info(num); if (pstu == NULL) { printf("不存在学号为%d的记录!\n", num); } else { printf("学号为%d的学生信息如下所示:\n", num); printf("学号:%d\t姓名:%s\t年龄:%d\t性别:%s\t地址:%s\t电话:%s\t电子邮件:%s\n", pstu->num, pstu->name, pstu->age, pstu->sex, pstu->address, pstu->telephone, pstu->email); } break; case 0: printf("欢迎下次使用,再见!\n"); if (!student_list) { //释放内存 free(student_list); } return 0; break; default: printf("输入错误,请重新选择操作!\n"); } } if (!student_list) { //释放内存 free(student_list); } return 0; }
//////////////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////// THE MAIN ////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////// void main() { float *a;//Will contain pointer pointing to the resultant matrix int choice; //////////////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////START OF MENU/////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////// do { choice=menu();//variable recieves option number selected by the user switch(choice) { case 0:choice=0; printf("\n\n\nTHANK YOU\n\n"); break; case 1:compatibility=1; get_input(compatibility);//will input all data into global struct A and B a=m_sum(X,Y);//ADDITION of struct matrix X,struct matrix Y show_output(a);//will print the result in matrix A[][] break; case 2:compatibility=1; get_input(compatibility);//will input all data into global struct A and B a=m_diff(X,Y);//Subraction of struct matrix X,struct matrix Y show_output(a);//will print the result in matrix A[][] break; case 3:compatibility=2; get_input(compatibility);//will input all data into global struct A and B a=m_prod(X,Y);//Product of struct matrix X,struct matrix Y show_output(a);//will print the result in matrix A[][] break; case 4:/* compatibility=2; get_input(compatibility); a=m_div(X,Y); show_output(a); */ break; case 5:/* compatibility=refer header comments; get_input(compatibility); a=m_funtion(input parameters); show_output(a); */ break; case 6:/* compatibility=refer header comments; get_input(compatibility); a=m_funtion(input parameters); show_output(a); */ break; case 7:/* compatibility=refer header comments; get_input(compatibility); a=m_funtion(input parameters); show_output(a); */ break; case 8:/* compatibility=refer header comments; get_input(compatibility); a=m_funtion(input parameters); show_output(a); */ break; case 9: compatibility=3; get_input(compatibility); a=m_reshape(X,Y); show_output(a); break; case 10: compatibility=0; get_input(compatibility); ans=m_det(X.arr,X.row_size*X.colm_size); printf("The result of the determinant is %f",ans); break; } }while(choice!=0); }
int main() { Employee employees[LEN_EMPLOYEES]; initEmployees(employees,LEN_EMPLOYEES); char seguir = 'S'; int id; char name[51]; char lastName[51]; float salary; int sector; do { system("cls");//system("clear"); switch(menu()) { case 1: system("cls");//system("clear"); printf("---------ALTA--------\n\n"); id = getId(); strncpy(name,getStringSoloLetras("Ingrese NOMBRE: "),51); strncpy(lastName,getStringSoloLetras("Ingrese APELLIDO: "),51); salary = getFloat("Ingrese SALARIO: "); sector = getInt("Ingrese SECTOR: "); system("cls");//system("clear"); if(addEmployee(employees,LEN_EMPLOYEES,id,name,lastName,salary,sector) == -1) { printf("Error al ingresar datos!"); } system("pause"); break; case 2: system("cls");//system("clear"); if(verifyAllEmpty(employees,LEN_EMPLOYEES) == 0) { printf("NO HAY EMPLEADOS INGRESADOS!\n"); } else { printf("------------MODIFICAR-----------\n\n"); printEmployees(employees,LEN_EMPLOYEES); id = getInt("\n\nIngrese ID del empleado que desea modificar: "); if(findEmployeeById(employees,LEN_EMPLOYEES,id) == -1) { printf("NO EXISTE ESTE EMPLEADO\n"); system("pause"); break; } if(modifyEmployee(employees,LEN_EMPLOYEES,id) == -1) { printf("\nError!"); } } system("pause"); system("cls");//system("clear"); break; case 3: system("cls");//system("clear"); if(verifyAllEmpty(employees,LEN_EMPLOYEES) == 0) { printf("NO HAY EMPLEADOS INGRESADOS!\n"); } else { printf("------------ELIMINAR-----------\n\n"); printEmployees(employees,LEN_EMPLOYEES); id = getInt("\n\nIngrese ID del empleado que desea eliminar: "); if(findEmployeeById(employees,LEN_EMPLOYEES,id) == -1) { printf("NO EXISTE ESTE EMPLEADO\n"); system("pause"); break; } if(removeEmployee(employees,LEN_EMPLOYEES,id) == -1) { printf("\nError!"); } } system("pause"); system("cls");//system("clear"); break; case 4: system("cls");//system("clear"); if(verifyAllEmpty(employees,LEN_EMPLOYEES) == 0) { printf("NO HAY EMPLEADOS INGRESADOS!\n"); } else { printf("------------INFORMAR-----------\n\n"); sortEmployees(employees,LEN_EMPLOYEES); printEmployees(employees,LEN_EMPLOYEES); } system("pause"); system("cls"); break; } }while(seguir == 'S'); return 0; }
int EventList::findEvents(void) { int res = 0; int event = 0; t_channel_id channel_id; //g_Zapit->getCurrentServiceID() CEventFinderMenu menu(&event, &m_search_epg_item, &m_search_keyword, &m_search_list, &m_search_channel_id, &m_search_bouquet_id); hide(); menu.exec(NULL, ""); if(event == 1) { res = 1; m_showChannel = true; // force the event list to paint the channel name evtlist.clear(); if(m_search_list == SEARCH_LIST_CHANNEL) { sectionsd_getEventsServiceKey(m_search_channel_id & 0xFFFFFFFFFFFFULL, evtlist, m_search_epg_item,m_search_keyword); } else if(m_search_list == SEARCH_LIST_BOUQUET) { int channel_nr = bouquetList->Bouquets[m_search_bouquet_id]->channelList->getSize(); for(int channel = 0; channel < channel_nr; channel++) { channel_id = bouquetList->Bouquets[m_search_bouquet_id]->channelList->getChannelFromIndex(channel)->channel_id; sectionsd_getEventsServiceKey(channel_id & 0xFFFFFFFFFFFFULL, evtlist, m_search_epg_item,m_search_keyword); } } else if(m_search_list == SEARCH_LIST_ALL) { CHintBox box(LOCALE_TIMING_EPG,g_Locale->getText(LOCALE_EVENTFINDER_SEARCHING)); box.paint(); int bouquet_nr = bouquetList->Bouquets.size(); for(int bouquet = 0; bouquet < bouquet_nr; bouquet++) { int channel_nr = bouquetList->Bouquets[bouquet]->channelList->getSize(); for(int channel = 0; channel < channel_nr; channel++) { channel_id = bouquetList->Bouquets[bouquet]->channelList->getChannelFromIndex(channel)->channel_id; sectionsd_getEventsServiceKey(channel_id & 0xFFFFFFFFFFFFULL,evtlist, m_search_epg_item,m_search_keyword); } } box.hide(); } sort(evtlist.begin(), evtlist.end(), sortByDateTime); current_event = (unsigned int)-1; time_t azeit=time(NULL); CChannelEventList::iterator e; for ( e = evtlist.begin(); e != evtlist.end(); ++e ) { if ( e->startTime > azeit ) { break; } current_event++; } if(evtlist.empty()) { if ( evtlist.size() == 0 ) { CChannelEvent evt; evt.description = g_Locale->getText(LOCALE_EPGVIEWER_NOTFOUND); evt.eventID = 0; evtlist.push_back(evt); } } if (current_event == (unsigned int)-1) current_event = 0; selected= current_event; name = g_Locale->getText(LOCALE_EVENTFINDER_SEARCH); name += ": '"; name += m_search_keyword; name += "'"; } paintHead(0); paint(); showFunctionBar(true); return(res); }
void str_cli(int sockfd) { char *sendline, recvline[MAXLINE], ch; message_t newMesg, recvMesg; int buffrecv; while(1) { ch = menu(); switch(ch) { case '1': printf("\n\nSIGN IN\n"); sendline = message_toString(getIdAndPassword(SIGNIN)); if (send(sockfd, sendline, MESSAGE_MAXLEN, 0) != MESSAGE_MAXLEN) { printf("send() sent a different number of bytes than expected\n"); } if (recv(sockfd, recvline, MESSAGE_MAXLEN, 0) < 0) { printf("str_cli: server terminated prematurely\n"); exit(1); } recvline[strlen(recvline)] = '\0'; newMesg = message_parse(recvline); switch(newMesg->cmd) { case SIGNIN: printf("\nWelcome to console chess game\n"); for(;;) { } mainConsoleChess(LIGHT, sockfd); break; default: printf("Fail to sign in\n"); break; } continue; case '2': printf("\n\nSIGN UP\n"); sendline = message_toString(getIdAndPassword(SIGNUP)); if (send(sockfd, sendline, MESSAGE_MAXLEN, 0) != MESSAGE_MAXLEN ) { printf("send() sent a different number of bytes than expected\n"); } if (recv(sockfd, recvline, MESSAGE_MAXLEN, 0) < 0) { printf("str_cli: server terminated prematurely\n"); exit(1); } recvline[strlen(recvline)] = '\0'; puts(recvline); //Debug newMesg = message_parse(recvline); switch(newMesg->cmd) { case SIGNUP: //printf("\nSuccessfull sign up id %s.\n", newMesg->arg); printf("\nSuccessfull sign up\n"); break; default: printf("Fail to sign up. Maybe this account doesn't exist\n"); break; } continue; case '3': printf("Exit\n", ch); sendline = message_toString(message_construct(SIGNOUT, "0", "0", "0", "0")); if (send(sockfd, sendline, MESSAGE_MAXLEN, 0) != MESSAGE_MAXLEN) { printf("send() sent a different number of bytes than expected\n"); } if (buffrecv = recv(sockfd, recvline, MESSAGE_MAXLEN, 0) < 0) { printf("str_cli: server terminated prematurely\n"); exit(1); } recvline[strlen(recvline)] = '\0'; puts(recvline); //Debug printf("\nI'm done!\n"); exit(0); break; default: printf("Wrong option! Please choose again\n"); continue; } break; } printf("\n"); }
//right-click the project and go to "Properties" //C/C++ Build -> Settings -> Tool Settings -> GCC C++ Compiler -> Miscellaneous -> Other Flags. Put -std=c++0x at the end int main() { int userChoice; // IN - User(s) menu selection int mainChoice; // IN - User(s) main menu selection int adminLogin; // IN - User(s) admin menu selection ifstream adminFile; adminFile.open("AdminInfo.txt"); //CALC - Opens input file menu userSelection; // INPUT (ENUM TYPE). mainMenu mainSelection; // INPUT (ENUM TYPE). string username; string password; string seanUsername; string seanPassword; string stevenUsername; string stevenPassword; bool validLogin; // CALC - Checks if adminLogin is valid validLogin = false; srand(time(0)); //Creates a vector containing the stadium class vector<stadium> S; //Reads input into the vector readInput(S); getline(adminFile, stevenUsername); getline(adminFile, stevenPassword); getline(adminFile, seanUsername); getline(adminFile, seanPassword); adminFile.close(); // FUNCTION mainChoice - This function is designed to DISPLAY // the main menu to the user(s). UserChoice(mainChoice, 3, 6); // PROCESS mainSelection = mainMenu(mainChoice); // WHILE LOOP - MAIN BODY LOOP while (mainChoice != EXITMAIN) { // SWITCH STATEMENT - switch(mainSelection) { // CASE EXIT - Exit Case. case EXITMAIN: break;// END OF CASE EXIT // CASE STADIUMNAME case STADIUMFINDER: // FUNCTION UserMenuChoice - This function is designed to DISPLAY // the menu to the user(s). UserChoice(userChoice, 0, 6); // PROCESS userSelection = menu(userChoice); // WHILE LOOP - MAIN BODY LOOP while (userChoice != EXIT) { // SWITCH STATEMENT - switch(userSelection) { // CASE EXIT - Exit Case. case EXIT: break;// END OF CASE EXIT // CASE STADIUMNAME case STADIUMNAME: //SORT function to sort the vector by stadium OutputMLG(S, 0); break; // END OF CASE STADIUMNAME // CASE TEAMNAME case TEAMNAME: //SORT function to sort the vector by teamName OutputMLG(S, 1); break; // END OF CASE TEAMNAME // CASE GRASSTOP case GRASSTOP: //SORT function to sort the vector by stadium OutputMLG(S, 2); break; // END OF CASE GRASSTOP // CASE LEAGUETYPE case LEAGUETYPE: OutputMLG(S, 4); break; // END OF CASE LEAGUETYPE // CASE LEAGUETYPE case DATEOFCREATION: OutputMLG(S, 3); break; // END OF CASE LEAGUETYPE // CASE RANDOMSTADIUM case RANDOMSTADIUM: randomStadium(S); break; // END OF CASE RANDOMSTADIUM // CASE DEFAULT - Default case. default: break; // END OF CASE DEFAULT }// END OF SWITCH STATEMENT // FUNCTION UserChoice - This function is designed to display // and grab the menu choice from the user(s). UserChoice(userChoice, 0, 6); // PROCESS userSelection = menu(userChoice); } //SORT function to sort the vector by stadium break; // END OF CASE STADIUMNAME // CASE TRIPPLANNER case TRIPPLANNER: // FUNCTION - TripPlanner - Method that helps the user plan their // travels, destination by destination tripPlanner(S); //SORT function to sort the vector by teamName break; // END OF CASE TEAMNAME // CASE SOUVENIRSHOP case SOUVENIRSHOP: cout << "\nTO BE INCLUDED LATER!\n"; //SORT function to sort the vector by stadium break; // END OF CASE GRASSTOP // CASE DISTANCE MEASURE case DISTANCEMEASURE: StoryTen(); break; // END OF CASE LEAGUETYPE // CASE LEAGUEVISIT case LEAGUEVISIT: cout << "\nTO BE INCLUDED LATER!\n"; break; // END OF CASE LEAGUETYPE // CASE ADMINLOGIN case ADMINLOGIN: if (validLogin == true) { cout << "\nYou are already logged in " << username << endl; } else { // USER INPUT - Input UserChoice(adminLogin, 4, 1); // CHECK IF USER WISHED TO PROCEED TO LOGIN if(adminLogin == 1) { while(validLogin == false) { cin.ignore(1000, '\n'); cout << "\nEnter Username(Case Sensitive): "; getline(cin, username); cout << "\nEnter Password(Case Sensitive): "; getline(cin, password); if((username == seanUsername && password == seanPassword)|| (username == stevenUsername && password == stevenPassword)) { cout << "\nWelcome " << username << endl; validLogin = true; break; } else { cout << "\nInvalid Login Information, please try again.\n"; } // USER INPUT - Input UserChoice(adminLogin, 4, 1); } } // END OF IF STATEMENT } break; // END OF CASE LEAGUETYPE // CASE DEFAULT - Default case. default: break; // END OF CASE DEFAULT }// END OF SWITCH STATEMENT // FUNCTION mainChoice - This function is designed to DISPLAY // the main menu to the user(s). UserChoice(mainChoice, 3, 6); // PROCESS mainSelection = mainMenu(mainChoice); } // // OutputMLG(S); // cout << S.size(); return 0; }
int main() { char **txt1 = NULL, **txt2 = NULL; short isprogend = 0, istxt1 = 0, istxt2 = 0, strct; SetConsoleCP(1251); SetConsoleOutputCP(1251); system("title = Курсовая работа. Обработка текста"); do { system("cls"); switch (menu()) { case '1': //ввод текста if (txt1 != NULL) txt1 = (char**)dsfree((void**)txt1, strct); if (txt2 != NULL) txt2 = (char**)(dsfree((void**)txt2, strct)); istxt1 = 1; istxt2 = 0; system("cls"); rewind(stdin); txt1 = gettxt(&strct); printf_s("\nВвод завершен!\n"); waitforenter(); break; case '2': //вывод исходного текста system("cls"); if (istxt1) { printf_s("Исходный текст:\n"); putstrings(txt1, strct); } else printf_s("Ошибка! Сначала введите исходный текст"); printf_s("\n"); waitforenter(); break; case '3': //обработка исходного текста system("cls"); if (istxt1) { if (txt2 == NULL) { istxt2 = 1; txt2 = wordproc(txt1, strct); printf_s("Текст обработан"); } else printf_s("Текст уже был обработан"); } else printf_s("Ошибка! Сначала введите исходный текст"); printf_s("\n"); waitforenter(); break; case '4': //вывод текста system("cls"); if (istxt2) { printf_s("Результирующий текст:\n"); putstrings(txt2, strct); } else printf_s("Ошибка! Сначала обработайте исходный текст"); printf_s("\n"); waitforenter(); break; case '5': //справка system("cls"); reference(); printf_s("\n"); waitforenter(); break; case '6': //выход system("cls"); printf_s("Вы уверены, что хотите выйти?(1-Да/0-Нет): "); scanf_s("%hi", &isprogend); rewind(stdin); break; default: printf_s("Ошибка! Введите существующий пункт меню\n"); waitforenter(); } } while (!isprogend); if (txt1 != NULL) txt1 = (char**)dsfree((void**)txt1, strct); if (txt1 != NULL) txt1 = (char**)dsfree((void**)txt1, strct); return 0; }
/* ----------------------------------------------------------------------- */ void FVpreOUpos(int BD) /* ----------------------------------------------------------------------- */ { int opcao; if ((teste1Flux)&&(grafSecundFlux == VAZIO)) { GraficoFluxSecund(); grafSecundFlux = BD; } else if (teste2Flux) { MelhorProvaCurvaFlux(ManobAtiva,NumManob); teste2Flux = FALSE; teste1Flux = TRUE ; GraficoFluxSecund(); } AtivaJanelaGrafica(GRAF1); Moldura(); ProcuraZero();/*procura melhor zero para aparelho */ if (ZeroOk) { inicFlux2 = inicFlux1; inicFlux1 = (inicFlux1 == areaTampaoInt) ? areaFlux : areaTampaoInt; Moldura(); /*********/ DesenhaEixos(30,435,15,220,0,105,41,25); ScalaFluxIni(); DesativaJanelaGrafica(GRAF1); AtivaJanelaGrafica(MENU_FLUXVOL); getviewsettings(&vp); Moldura(); menuFlux[0] = "INICIAR"; menuFlux[1] = "ANULAR"; setcolor(COR4); settextjustify(CENTER_TEXT,TOP_TEXT); /********/ outtextxy((vp.right-vp.left)/2,36,menuFlux[1]); do { ++NumManob; testFluxOk = FALSE; opcao = menu(MENU_FLUXVOL,3,menuFlux); /**** clocar parametros */ if (opcao == INICIAR) { DesativaJanelaGrafica(MENU_FLUXVOL); AtivaJanelaGrafica(GRAF1); CurvaFluxVol(0); testFluxOk = TRUE; DesativaJanelaGrafica(GRAF1); } } while((opcao != ANULAR)&&(!testFluxOk)); if ((opcao == ANULAR)||(Abortou)) { --NumManob; inicFlux1 = inicFlux2; } AtivaJanelaGrafica(MENU_FLUXVOL); clearviewport(); menuFlux[0] = "PRE-FARMACODINAMICA";/***************/ menuFlux[1] = "POS-FARMACODINAMICA"; menuFlux[2] = "RETORNAR"; setcolor(COR4); settextjustify(CENTER_TEXT,TOP_TEXT); /********/ outtextxy((vp.right-vp.left)/2,26,menuFlux[0]); /********/ outtextxy((vp.right-vp.left)/2,36,menuFlux[1]); /********/ outtextxy((vp.right-vp.left)/2,46,menuFlux[2]); } else /* !ZeroOk */ DesativaJanelaGrafica(GRAF1); } /* FVpreOUpos */
void ListTasks::contextMenuEvent(QContextMenuEvent *event) { Item* item = getCurrentItem(); if( item == NULL) return; QMenu menu(this); QAction *action; int id = item->getId(); switch( id) { case ItemJobBlock::ItemId: { ItemJobBlock *itemBlock = (ItemJobBlock*)item; if( itemBlock->files.size() ) { action = new QAction( "Browse Files...", this); connect( action, SIGNAL( triggered() ), this, SLOT( actBrowseFolder() )); menu.addAction( action); menu.addSeparator(); } QMenu * submenu = new QMenu( "Change Block", this); itemBlock->generateMenu( itemBlock->getNumBlock(), &menu, this, submenu); menu.addMenu( submenu); menu.addSeparator(); submenu = new QMenu( "Change Tasks", this); menu.addMenu( submenu); action = new QAction( "Set Command", this); connect( action, SIGNAL( triggered() ), this, SLOT( actBlockCommand() )); submenu->addAction( action); action = new QAction( "Set Working Directory", this); connect( action, SIGNAL( triggered() ), this, SLOT( actBlockWorkingDir() )); submenu->addAction( action); action = new QAction( "Set Post Command", this); connect( action, SIGNAL( triggered() ), this, SLOT( actBlockCmdPost() )); submenu->addAction( action); action = new QAction( "Set Files", this); connect( action, SIGNAL( triggered() ), this, SLOT( actBlockFiles() )); submenu->addAction( action); action = new QAction( "Set Service Type", this); connect( action, SIGNAL( triggered() ), this, SLOT( actBlockService() )); submenu->addAction( action); action = new QAction( "Set Parser Type", this); connect( action, SIGNAL( triggered() ), this, SLOT( actBlockParser() )); submenu->addAction( action); break; } case ItemJobTask::ItemId: { ActionId * actionid = new ActionId( 0, "Output", this); connect( actionid, SIGNAL( triggeredId( int ) ), this, SLOT( actTaskStdOut( int ) )); menu.addAction( actionid); if( m_job_id != AFJOB::SYSJOB_ID ) { int startCount = ((ItemJobTask*)(item))->taskprogress.starts_count; if( startCount > 1 ) { QMenu * submenu = new QMenu( "outputs", this); for( int i = 1; i < startCount; i++) { actionid = new ActionId( i, QString("session #%1").arg(i), this); connect( actionid, SIGNAL( triggeredId( int ) ), this, SLOT( actTaskStdOut( int ) )); submenu->addAction( actionid); } menu.addMenu( submenu); } } action = new QAction( "Log", this); connect( action, SIGNAL( triggered() ), this, SLOT( actTaskLog() )); menu.addAction( action); action = new QAction( "Info", this); connect( action, SIGNAL( triggered() ), this, SLOT( actTaskInfo() )); menu.addAction( action); action = new QAction( "Listen", this); connect( action, SIGNAL( triggered() ), this, SLOT( actTaskListen() )); menu.addAction( action); action = new QAction( "Error Hosts", this); connect( action, SIGNAL( triggered() ), this, SLOT( actTaskErrorHosts() )); menu.addAction( action); std::vector<std::string> files = ((ItemJobTask*)(item))->genFiles(); if( files.size()) { if( af::Environment::getPreviewCmds().size() > 0 ) { menu.addSeparator(); action = new QAction( "Browse Files...", this); connect( action, SIGNAL( triggered() ), this, SLOT( actBrowseFolder() )); menu.addAction( action); if( ((ItemJobTask*)(item))->isBlockNumeric() ) { QMenu * submenu_cmd = new QMenu( "Preview", this); int p = 0; for( std::vector<std::string>::const_iterator it = af::Environment::getPreviewCmds().begin(); it != af::Environment::getPreviewCmds().end(); it++, p++) { if( files.size() > 1) { QString file = afqt::stoq((*it).c_str()); QMenu * submenu_img = new QMenu( QString("%1").arg( file), this); for( int i = 0; i < files.size(); i++) { QString imgname = file.right(99); ActionIdId * actionid = new ActionIdId( p, i, imgname, this); connect( actionid, SIGNAL( triggeredId(int,int) ), this, SLOT( actTaskPreview(int,int) )); submenu_img->addAction( actionid); } submenu_cmd->addMenu( submenu_img); } else { ActionIdId * actionid = new ActionIdId( p, 0, QString("%1").arg( QString::fromUtf8((*it).c_str())), this); connect( actionid, SIGNAL( triggeredId(int,int) ), this, SLOT( actTaskPreview(int,int) )); submenu_cmd->addAction( actionid); } }
static void console_main(void) { while (!g.quit) { char input[32]; struct peer *peer; pj_status_t status; menu(); fgets(input, sizeof(input), stdin); switch (input[0]) { case 'a': create_relay(); break; case 'd': pj_pool_factory_dump(&g.cp.factory, PJ_TRUE); break; case 's': if (g.relay == NULL) { puts("Error: no relay"); continue; } if (input[1]!='s') peer = &g.peer[0]; else peer = &g.peer[1]; strcpy(input, "Hello from client"); status = pj_turn_sock_sendto(g.relay, (const pj_uint8_t*)input, strlen(input)+1, &peer->mapped_addr, pj_sockaddr_get_len(&peer->mapped_addr)); if (status != PJ_SUCCESS) my_perror("turn_udp_sendto() failed", status); break; case 'b': if (g.relay == NULL) { puts("Error: no relay"); continue; } if (input[1]!='b') peer = &g.peer[0]; else peer = &g.peer[1]; status = pj_turn_sock_bind_channel(g.relay, &peer->mapped_addr, pj_sockaddr_get_len(&peer->mapped_addr)); if (status != PJ_SUCCESS) my_perror("turn_udp_bind_channel() failed", status); break; case 'x': if (g.relay == NULL) { puts("Error: no relay"); continue; } destroy_relay(); break; case '0': case '1': if (g.relay == NULL) { puts("No relay"); break; } peer = &g.peer[input[0]-'0']; sprintf(input, "Hello from peer%d", input[0]-'0'); pj_stun_sock_sendto(peer->stun_sock, NULL, input, strlen(input)+1, 0, &g.relay_addr, pj_sockaddr_get_len(&g.relay_addr)); break; case 'q': g.quit = PJ_TRUE; break; } } }
void kmain(multiboot_info_t* mbd, unsigned int magic ) { if ( magic != 0x2BADB002 ) { // TODO: Hacer un kputs. kprint ( "Warning: No se inicializo con GRUB, intentando de todas formas.\n" ); } //Primero tenemos que corregir mbd para que sea una direccion virtual valida mbd = (multiboot_info_t*)( PA2KVA( (uint32_t) mbd) ); //Ahora si, usando mbd que apunta bien a los datos del grub, inicializamos todo kinit( mbd ); kprint("llego\n"); key_init(); //Aca asigna Esc a la funcion menu key_register(menu, 1); //Seteo Fs key_register(mostrar_slot,59); key_register(mostrar_slot,60); key_register(mostrar_slot,61); key_register(mostrar_slot,62); key_register(mostrar_slot,63); key_register(mostrar_slot,64); key_register(mostrar_slot,65); key_register(mostrar_slot,66); key_register(mostrar_slot,67); kprint("binding keys done\n"); if(tty_init(&tty_kernel, menu_in)) { panic("fallo el inicio de las tty"); } //Lanzamos programa para cargar tareas y modificar quantums. set_isr_handler( 14, &pf ); // #PF // El idle task... siempre listo... :-) programs_t idle; idle.va_entry = idletask; crear_kthread( &idle, 10 ); //Iniciamos Scheduler iniciar_scheduler(); extern unsigned char ej1[]; extern unsigned char ej2[]; extern unsigned char ej3[]; extern unsigned char ej4[]; programas[0] = (programs_t *) ej1; programas[1]= (programs_t *) ej2; programas[2] = (programs_t *) ej3; programas[3]= (programs_t *) ej4; programas[4]= (programs_t *) ej1; set_irq_handler( 0, &timer ); set_irq_handler( 1, &irq_keyboard ); menu(1); sti(); //Lanzamos programa menu while(1); }
void main() { int sss,q,ll,gd=DETECT,p,gm,area,a=(450-(50*5)),d,cat=77,ch,dh,eh,t1,t2,t12,t22,len,cc,hh; char *str,*str1,*tim; initgraph(&gd,&gm,""); p=1; front(); dr: viewport(); q=menu(); if(q==3) { arun: hh=help(); if(hh==1) { how(); goto arun; } if(hh==2) { select(); goto arun; } if(hh==3) { credit(); goto arun; } if(hh==4) { design(); goto arun; } if(hh==5) goto dr; } if(q==2) { rr: ll=sivakumar(); if(ll==1) { p=m2(); goto rr; } if(ll==2) { a=speed(); viewport(); goto rr; } if(ll==3) { topscore(); goto rr; } if(ll==4) goto dr; } if(q==4) exit(0); if(q==1) { names(); hide(); viewport(); x[0]=85; x[1]=70; x[2]=55; x[3]=40; y[0]=y[1]=y[2]=y[3]=35; setcolor(4); rectangle(24,19,626,396); ra(); setcolor(15); setfillstyle(1,10); bar(32,32,43,43); area=imagesize(30,30,45,45); buff=malloc(area); getimage(30,30,45,45,buff); putimage(30,30,buff,XOR_PUT); setpos(0,0); setfillstyle(1,0); bar(100,100,500,350); prakash(p); level=p; putimage(40,35,buff,XOR_PUT); putimage(55,35,buff,XOR_PUT); putimage(70,35,buff,XOR_PUT); putimage(85,35,buff,XOR_PUT); textcolor(GREEN+BLINK); len=0; status("Game Play: Arrow keys Menu: Esc Pause (or) Play: Others key"); while(1) { sss=getpixel(5,5); if(sss!=0); { setfillstyle(SOLID_FILL,0); bar(0,0,15,15); } if(((i-4)%11==0)&&(bon==0)&&(len!=(i-4))) { len=(i-4); gettime(&t); bonous(); bon=1; t1=t.ti_sec; cc=10; } gettime(&t); if((t1!=t.ti_sec)&&(bon==1)) { cc--; t1=t.ti_sec; itoa(cc,tim,10); setfillstyle(SOLID_FILL,0); bar(470,0,530,18); outtextxy(500,0,tim); } if((cc==0)&&(bon==1)) { putimage(xc1,yc1,f2,XOR_PUT); bar(470,0,530,18); bon=0; } gotoxy(68,1); setcolor(6); itoa(score,str,10); setfillstyle(1,0); settextstyle(3,0,1); if(strcmp(str,str1)!=0) { bar(80,400,350,450); outtextxy(100,420,"Score : "); outtextxy(180,420,str); strcpy(str1,str); } if(kbhit()) { // ch=getch(); dh=getch(); cat=dh; } else { arrange(x,y,i); if(set==0) food(); if(cat!=dupli) cat=lock(cat,dupli); switch(cat) { case 72: if(y[1]==20) y[0]=380; else y[0]=y[1]-15; x[0]=x[1]; d=getpixel(x[0]+8,y[0]+8); if((d==10)||(d==14)) doctor(); if((d==4)&&(bon==1)) { i++; sound(1000); delay(90); nosound(); bon=0; score+=(cc*10); putimage(xc1,yc1,f2,XOR_PUT); putimage(x[0],y[0],buff,XOR_PUT); putimage(x[i],y[i],buff,XOR_PUT); setfillstyle(SOLID_FILL,0); bar(470,0,530,18); } else if(d==15) { i++; set=0; sound(800); delay(40); score+=bb; nosound(); putimage(x[0],y[0],buff,XOR_PUT); } else { putimage(x[0],y[0],buff,XOR_PUT); putimage(x[i-1],y[i-1],buff,XOR_PUT); } delay(a); break; case 80: if(y[1]==380) y[0]=20; else y[0]=y[1]+15; x[0]=x[1]; d=getpixel(x[0]+8,y[0]+8); if((d==10)||(d==14)) doctor(); if((d==4)&&(bon==1)) { i++; sound(1000); delay(90); nosound(); bon=0; score+=(cc*10); putimage(xc1,yc1,f2,XOR_PUT); putimage(x[0],y[0],buff,XOR_PUT); putimage(x[i],y[i],buff,XOR_PUT); setfillstyle(SOLID_FILL,0); bar(470,0,530,18); } else if(d==15) { i++; score+=bb; sound(800); delay(40); set=0; nosound(); putimage(x[0],y[0],buff,XOR_PUT); } else { putimage(x[0],y[0],buff,XOR_PUT); putimage(x[i-1],y[i-1],buff,XOR_PUT); } delay(a); break; case 75: if(x[1]==25) x[0]=610; else x[0]=x[1]-15; y[0]=y[1]; d=getpixel(x[0]+8,y[0]+8); if((d==10)||(d==14)) doctor(); if((d==4)&&(bon==1)) { i++; sound(1000); delay(90); nosound(); bon=0; score+=(cc*10); putimage(xc1,yc1,f2,XOR_PUT); putimage(x[0],y[0],buff,XOR_PUT); putimage(x[i],y[i],buff,XOR_PUT); setfillstyle(SOLID_FILL,0); bar(470,0,530,18); } else if(d==15) { i++; sound(800); delay(40); set=0; nosound(); score+=bb; putimage(x[0],y[0],buff,XOR_PUT); } else { putimage(x[0],y[0],buff,XOR_PUT); putimage(x[i-1],y[i-1],buff,XOR_PUT); } delay(a); break; case 77: if(x[1]==610) x[0]=25; else x[0]=x[1]+15; y[0]=y[1]; d=getpixel(x[0]+8,y[0]+8); if((d==10)||(d==14)) doctor(); if((d==4)&&(bon==1)) { i++; sound(1000); delay(90); nosound(); bon=0; score+=(cc*10); putimage(xc1,yc1,f2,XOR_PUT); putimage(x[0],y[0],buff,XOR_PUT); putimage(x[i],y[i],buff,XOR_PUT); setfillstyle(SOLID_FILL,0); bar(470,0,530,18); } else if(d==15) { i++; set=0; sound(800); delay(40); score+=bb; nosound(); putimage(x[0],y[0],buff,XOR_PUT); } else { putimage(x[0],y[0],buff,XOR_PUT); putimage(x[i-1],y[i-1],buff,XOR_PUT); } delay(a); break; case 27: goto dx; // break; } dupli=cat; } } } dx: call(); }
void BookmarksContentsWidget::showContextMenu(const QPoint &point) { const QModelIndex index(m_ui->bookmarksViewWidget->indexAt(point)); const BookmarksModel::BookmarkType type(static_cast<BookmarksModel::BookmarkType>(index.data(BookmarksModel::TypeRole).toInt())); QMenu menu(this); if (type == BookmarksModel::TrashBookmark) { menu.addAction(ThemesManager::getIcon(QLatin1String("trash-empty")), tr("Empty Trash"), BookmarksManager::getModel(), SLOT(emptyTrash()))->setEnabled(BookmarksManager::getModel()->getTrashItem()->rowCount() > 0); } else if (type == BookmarksModel::UnknownBookmark) { menu.addAction(ThemesManager::getIcon(QLatin1String("inode-directory")), tr("Add Folder"), this, SLOT(addFolder())); menu.addAction(tr("Add Bookmark"), this, SLOT(addBookmark())); menu.addAction(tr("Add Separator"), this, SLOT(addSeparator())); } else { const bool isInTrash(index.data(BookmarksModel::IsTrashedRole).toBool()); menu.addAction(ThemesManager::getIcon(QLatin1String("document-open")), tr("Open"), this, SLOT(openBookmark())); menu.addAction(tr("Open in New Tab"), this, SLOT(openBookmark()))->setData(WindowsManager::NewTabOpen); menu.addAction(tr("Open in New Background Tab"), this, SLOT(openBookmark()))->setData(static_cast<int>(WindowsManager::NewTabOpen | WindowsManager::BackgroundOpen)); menu.addSeparator(); menu.addAction(tr("Open in New Window"), this, SLOT(openBookmark()))->setData(WindowsManager::NewWindowOpen); menu.addAction(tr("Open in New Background Window"), this, SLOT(openBookmark()))->setData(static_cast<int>(WindowsManager::NewWindowOpen | WindowsManager::BackgroundOpen)); if (type == BookmarksModel::SeparatorBookmark || (type == BookmarksModel::FolderBookmark && index.child(0, 0).data(BookmarksModel::TypeRole).toInt() == 0)) { for (int i = 0; i < menu.actions().count(); ++i) { menu.actions().at(i)->setEnabled(false); } } MainWindow *mainWindow(MainWindow::findMainWindow(this)); Action *bookmarkAllOpenPagesAction(new Action(ActionsManager::BookmarkAllOpenPagesAction, this)); bookmarkAllOpenPagesAction->setEnabled(mainWindow && mainWindow->getWindowsManager()->getWindowCount() > 0); Action *copyLinkAction(new Action(ActionsManager::CopyLinkToClipboardAction, this)); copyLinkAction->setEnabled(type == BookmarksModel::UrlBookmark); menu.addSeparator(); menu.addAction(ActionsManager::getAction(ActionsManager::BookmarkPageAction, this)); menu.addAction(bookmarkAllOpenPagesAction); menu.addSeparator(); menu.addAction(copyLinkAction); if (!isInTrash) { menu.addSeparator(); QMenu *addMenu(menu.addMenu(tr("Add Bookmark"))); addMenu->addAction(ThemesManager::getIcon(QLatin1String("inode-directory")), tr("Add Folder"), this, SLOT(addFolder())); addMenu->addAction(tr("Add Bookmark"), this, SLOT(addBookmark())); addMenu->addAction(tr("Add Separator"), this, SLOT(addSeparator())); } if (type != BookmarksModel::RootBookmark) { menu.addSeparator(); if (isInTrash) { menu.addAction(tr("Restore Bookmark"), this, SLOT(restoreBookmark())); } else { menu.addAction(getAction(ActionsManager::DeleteAction)); } menu.addSeparator(); menu.addAction(tr("Properties…"), this, SLOT(bookmarkProperties())); } connect(bookmarkAllOpenPagesAction, SIGNAL(triggered(bool)), this, SLOT(triggerAction())); connect(copyLinkAction, SIGNAL(triggered(bool)), this, SLOT(triggerAction())); } menu.exec(m_ui->bookmarksViewWidget->mapToGlobal(point)); }
bool AddressWidget::eventFilter(QObject *object, QEvent *event) { if (object == m_bookmarkLabel && m_bookmarkLabel && event->type() == QEvent::MouseButtonPress) { QMouseEvent *mouseEvent = static_cast<QMouseEvent*>(event); if (mouseEvent && mouseEvent->button() == Qt::LeftButton) { if (m_bookmarkLabel->isEnabled()) { const QString url = getUrl().toString(); if (BookmarksManager::hasBookmark(url)) { BookmarksManager::deleteBookmark(url); } else { BookmarksItem *bookmark = new BookmarksItem(UrlBookmark, getUrl().adjusted(QUrl::RemovePassword), m_window->getTitle()); BookmarkPropertiesDialog dialog(bookmark, NULL, this); if (dialog.exec() == QDialog::Rejected) { delete bookmark; } } updateBookmark(); } return true; } } if (object != this && event->type() == QEvent::ContextMenu) { QContextMenuEvent *contextMenuEvent = static_cast<QContextMenuEvent*>(event); if (contextMenuEvent) { QMenu menu(this); QAction *action = menu.addAction(tr("Remove This Icon"), this, SLOT(removeIcon())); action->setData(object->objectName()); menu.exec(contextMenuEvent->globalPos()); contextMenuEvent->accept(); return true; } } if (object == this && event->type() == QEvent::KeyPress && m_window) { QKeyEvent *keyEvent = static_cast<QKeyEvent*>(event); if (keyEvent->key() == Qt::Key_Escape) { const QUrl url = m_window->getUrl(); if (text().trimmed().isEmpty() || text().trimmed() != url.toString()) { setText((url.scheme() == QLatin1String("about") && m_window->isUrlEmpty()) ? QString() : url.toString()); if (!text().trimmed().isEmpty() && SettingsManager::getValue(QLatin1String("AddressField/SelectAllOnFocus")).toBool()) { QTimer::singleShot(0, this, SLOT(selectAll())); } } else { m_window->setFocus(); } } } return QLineEdit::eventFilter(object, event); }
int main(int argc, char **argv) { printf("bmig version %s\n", VERSION); // no command, needs a menu if (argc < 2) { menu(); return 0; } parse_flags(argc, (const char **)argv); char *command = argv[1]; // init if necessary if (strcmp(command, "init") == 0) { printf("beginning init process...\n"); // check for config.json file FILE *config = fopen("config.json", "r"); if (config == NULL) { char in_host[100]; char in_user[100]; char in_pass[100]; char in_db[100]; printf("\n"); // collect data printf("host [localhost]: "); fgets(in_host, 100, stdin); printf("db user [root]: "); fgets(in_user, 100, stdin); printf("db password [root]: "); fgets(in_pass, 100, stdin); needdb: printf("db name: "); fgets(in_db, 100, stdin); if (strcmp(in_db, "\n") == 0) { printf("please provide a db name\n"); goto needdb; } // strip \n char *pos; if ((pos = strchr(in_host, '\n')) != NULL) *pos = '\0'; if ((pos = strchr(in_user, '\n')) != NULL) *pos = '\0'; if ((pos = strchr(in_pass, '\n')) != NULL) *pos = '\0'; if ((pos = strchr(in_db, '\n')) != NULL) *pos = '\0'; // apply defaults, if applicable if (strcmp(in_host, "") == 0) { strcpy(in_host, "localhost"); } if (strcmp(in_user, "") == 0) { strcpy(in_user, "root"); } if (strcmp(in_pass, "") == 0) { strcpy(in_pass, "root"); } // create the config file char template[450];
void FmFileView::initMenu() { HbAction *action = 0; #ifdef FM_CHANGE_ORIENT_ENABLE action = new HbAction( this ); action->setObjectName( "rotateAction" ); action->setText( hbTrId( "Change orientation" ) ); menu()->addAction( action ); #endif // mStyleAction = new HbAction(); // mStyleAction->setObjectName( "switchStyle" ); // menu()->addAction( mStyleAction ); mSelectableAction = new HbAction(); mSelectableAction->setObjectName( "setSelectable" ); menu()->addAction( mSelectableAction ); connect( mSelectableAction, SIGNAL( triggered() ), this, SLOT( on_setSelectable_triggered() ), Qt::QueuedConnection ); action = new HbAction(); action->setObjectName( "delete" ); action->setText( hbTrId( "txt_common_opt_delete" ) ); menu()->addAction( action ); connect( action, SIGNAL( triggered() ), this, SLOT( on_delete_triggered() ), Qt::QueuedConnection ); action = new HbAction(); action->setObjectName( "copy" ); action->setText( hbTrId( "txt_common_opt_copy_to_folder" ) ); menu()->addAction( action ); connect( action, SIGNAL( triggered() ), this, SLOT( on_copy_triggered() ), Qt::QueuedConnection ); action = new HbAction(); action->setObjectName( "move" ); action->setText( hbTrId( "txt_common_opt_move_to_folder" ) ); menu()->addAction( action ); connect( action, SIGNAL( triggered() ), this, SLOT( on_move_triggered() ), Qt::QueuedConnection ); action = new HbAction(); action->setObjectName( "newFolder" ); action->setText( hbTrId( "txt_fmgr_opt_new_folder" ) ); menu()->addAction( action ); connect( action, SIGNAL( triggered() ), this, SLOT( on_newFolder_triggered() ), Qt::QueuedConnection ); HbMenu *subMenu = new HbMenu( hbTrId( "Sort" ) ); HbAction *sortNameAction = new HbAction( subMenu ); sortNameAction->setObjectName( "sortNameAction" ); sortNameAction->setText( hbTrId( "Sort by name" ) ); subMenu->addAction( sortNameAction ); HbAction *sortTimeAction = new HbAction( subMenu ); sortTimeAction->setObjectName( "sortTimeAction" ); sortTimeAction->setText( hbTrId( "Sort by time" ) ); subMenu->addAction( sortTimeAction ); HbAction *sortSizeAction = new HbAction( subMenu ); sortSizeAction->setObjectName( "sortSizeAction" ); sortSizeAction->setText( hbTrId( "Sort by size" ) ); subMenu->addAction( sortSizeAction ); HbAction* sortTypeAction = new HbAction( subMenu ); sortTypeAction->setObjectName( "sortTypeAction" ); sortTypeAction->setText( hbTrId( "Sort by type" ) ); subMenu->addAction( sortTypeAction ); menu()->addMenu( subMenu ); connect( sortNameAction, SIGNAL( triggered() ), this, SLOT( on_sortNameAction_triggered() ), Qt::QueuedConnection ); connect( sortTimeAction, SIGNAL( triggered() ), this, SLOT( on_sortTimeAction_triggered() ), Qt::QueuedConnection ); connect( sortSizeAction, SIGNAL( triggered() ), this, SLOT( on_sortSizeAction_triggered() ), Qt::QueuedConnection ); connect( sortTypeAction, SIGNAL( triggered() ), this, SLOT( on_sortTypeAction_triggered() ), Qt::QueuedConnection ); mMenu = takeMenu(); }
/* main function */ int main(int argc, char *argv[]) { int ret = 0, d, index; char shortoptions[] = "i:s:p:m:f:l:h:b:t:c:?"; DBGENTER; /* by default use composite */ for (;;) { d = getopt_long(argc, argv, shortoptions, (void *)NULL, &index); if (-1 == d) break; switch (d) { case 'f': field = atoi(optarg); break; case 'i': vpfe_input = atoi(optarg); break; case 'm': input_std = atoi(optarg); break; case 'p': printfn = atoi(optarg); case 's': case 'S': stress_test = atoi(optarg); break; case 'l': case 'L': cr_width = atoi(optarg); break; case 'h': case 'H': cr_height = atoi(optarg); break; case 'b': case 'B': cr_left = atoi(optarg); break; case 't': case 'T': cr_top = atoi(optarg); break; case 'c': case 'C': crop_en = atoi(optarg); break; default: menu(); exit(1); } } if (en_capture_to_file) { fp_capture = fopen(FILE_CAPTURE, "wb"); if (fp_capture == NULL) { printf("Unable to open file %s for capture\n", FILE_CAPTURE); exit(1); } } ret = vpbe_UE_1(); DBGEXIT; return ret; }
int main(void) { menu(); }
int main() { menu(); return 0; }
int main(int argc, char *argv[]) { puts ("MPEG-2 decoder : TSdecode.exe"); printf("Peter Daniel Version : %s \n", version); puts ("=============================\n"); if (argc == 1) { display_usage(); exit_prog(""); } while ((argc > 1) && (argv[1][0] == '-')) { switch (argv[1][1]) { case 'i': ip_filepath = &argv[1][2]; break; case 'p': search_PID = atoi(&argv[1][2]); break; case 'q': quite_mode = 1; break; default: printf("Bad option %s\n", argv[1]); display_usage(); exit_prog(""); } ++argv; --argc; } ip_file_length = get_ip_file_length(ip_filepath); printf("Opening MPEG-2 file %s, %d bytes.\n", ip_filepath, ip_file_length); printf("Search PID : %d", search_PID); ip_file = fopen(ip_filepath, "rb"); char menu_choice = 0; find_TS_sync_byte(); // synchronise to sync_bytes // display_sync_byte_table(); // display location of sync_bytes puts("\n5 occurances of Transport Stream sync_byte 0x47 found ok.\n"); fseek(ip_file, sync_bytes[1], 0); // go back to first sync_byte menu_choice = menu(); // display menu options switch (menu_choice) // decode menu choice { case '1' : // TS header decode menu_option1(); break; case '2' : // PID address table menu_option2(); break; case '3' : // Save PID address table menu_option3(); break; case '4' : // Extract PES menu_option4(); break; case '5' : // exit exit_prog(""); break; default: puts("\nERROR : Not a valid menu entry."); } exit_prog(""); return 0; }
/* ----------------------------------------------------------------------- */ void FluxVol() /* ----------------------------------------------------------------------- */ { int opcao,opc; char *opcoes[NUMOPC] = {"BRONCO-DILATACAO","BRONCO-PROVOCACAO", "ESPIROMETRIA DE ESFORCO","POS SIMPLES", "RETORNAR"}; char *menuFlux[3] = { "PRE-TESTE","POS-TESTE","RETORNAR"}; /* cria todas as janelas de fluxvol, coloca dados do paciente e ativajanela de menu */ AmbienteFluxVol(); if (*ApontFluxPreBD==NULL){ ManobAtivaPreBD = ManobAtivaPosBD = ManobAtiva = 1; NumManobPreBD = NumManobPosBD = NumManob = 0; *UltimaManobra = NULL; grafSecundFlux = VAZIO; } else { if (UltimaManobra == ApontFluxPreBD) { VariaveisTemporarias(preBD); grafSecundFlux = preBD; } else { VariaveisTemporarias(posBD); grafSecundFlux = posBD; } GraficoFluxSecund(); } teste2Flux = FALSE; /* desenha o menu e devolve a opcao escolhida */ while ((opcao = menu(MENU_FLUXVOL,NUM,menuFlux)) != RETORNAR){ /* ativa as provas */ Abortou = FALSE; switch(opcao){ case ESC : setcolor(COR_MOLDURA); break; case preBD : FVpreBD(); break; case posBD : while((opc=menu(POSFARM,NUMOPC,opcoes)) != 4){ switch (opc){ case ESC : setcolor(COR_MOLDURA); break; case 0 : broncoDilatacao(); break; case 1 : BroncoRestricao(); break; case 2 : Esforco(); break; case 3 : FVposBD(); break; case 4 : break; } /* switch posBD */ LimpaTela(); AmbienteFluxVol(); } /* while opc */ } /* switch opcao */ } /* while opcao */ setcolor(COR4); if (teste2Flux) MelhorProvaCurvaFlux(ManobAtiva,NumManob); if ((UltimaManobra == ApontFluxPreBD)&&(*ApontFluxPreBD != NULL)) { VariaveisReais(preBD); areaFlux = ApontFluxPreBD = UltimaManobra = areaFluxPreBD; } else if ((UltimaManobra == ApontFluxPosBD)&&(*ApontFluxPosBD != NULL)) { VariaveisReais(posBD); areaFlux = ApontFluxPosBD = UltimaManobra = areaFluxPosBD; } ConfereApontador(); if (*ApontFluxPosBD != NULL) (void) ImprimeFlux(0); } /* FluxVol */
UIActionMenuOpticalDevices(UIActionPool *pParent) : UIActionMenu(pParent, ":/cd_16px.png", ":/cd_disabled_16px.png") { qobject_cast<UIMenu*>(menu())->setShowToolTips(true); retranslateUi(); }
bus(){ scanf("%d", &opc); menu(opc); while(opc != 0){ switch(opc){ case 1: printf("Digite a Linha de Origem e Destino do Onibus: "); scanf(" % [\n^]s % [\n^]s",&orig , &dest); for(i=0; i < 44; i++){ if((CompararStrings(orig,onibus[i].origem)== 0) && (CompararStrings(dest, onibus[i].destino) == 0)){ printf("\n %s ",onibus[i].horario); } } break; case 2: for(i = 0; i < 44; i++){ if(lotado == onibus[i].lotado) printf("%d", onibus[i].numero); else printf("\nTodos Os ônibus possuem lugares disponíveis"); } break; case 3: printf("Digite o numero da linha do ônibus: "); scanf("%d", &numLinha); for(i= 0; i < 44; i++){ if(numLinha == onibus[i].numero){ int velMedia = 80; //KM/h int duracaoViagem = onibus[i].distancia/ velMedia; // em HORAS int horaChegada = onibus[i].horario + duracaoViagem; printf("A hora de chegada está estipulada em %d hs e a duração total em %d hs",horaChegada,duracaoViagem); } } break; case 4: printf("Digite o numero da linha do ônibus: "); scanf("%d", &numLinha); for(i = 0; i < 44; i++){ if(numLinha == onibus[i].numero && onibus[i].lotado != lotado){ printf("\nO onibus tem %d poltronas livres", onibus[i].polLivre); int porcentLivre = onibus[i].polLivre*100/44; printf("\n A porcentagem de ocupação é: %d porcento",porcentLivre - 100); } } break; case 5: for(i=0;i < 44;i++){ if(onibus[i].lotado != lotado){ printf("\nO Onibus %d tem %d %% de Poltronas na Janela Ocupadas",onibus[i].numero, onibus[i].janelasOcupadas*100/22); printf("\nO Onibus %d tem %d %% de Poltronas no Corredor Ocupadas",onibus[i].numero, onibus[i].corredorOcupadas*100/22); printf("\nO onibus %d tem %d poltronas livres", onibus[i].polLivre, onibus[i].numero); } } break; case 0: exit(0); opc = 0; break; } } }