void main() { char answer[100]; printf("Enter part to search for the name of the part\r\n\n"); printf("Enter number to search for the number of the part\r\n\n"); printf("enter change if you want to change the quantity of a current product\r\n\n"); printf("Enter add part to add an item to the database\r\n\n"); printf("If you want to read the whole database then please enter read\n\r\n"); printf("If you want to exit, enter quit\r\n\n"); gets(answer); if(answer[0]=='N'||answer[0]=='n'){get_number();} else if(answer[0]=='P'||answer[0]=='p'){get_part_name();} else if(answer[0]=='C'||answer[0]=='c'){change_quantity();} else if(answer[0]=='A'||answer[0]=='a'){add_part();} else if(answer[0]=='R'||answer[0]=='r'){read_out();} else if(answer[0]=='Q'||answer[0]=='q'){exit(0);} else { printf("Answer was none of the statements , thank you for using this\r\n"); } }
int main() { int ary[SIZE]; input(ary); read_out(ary); average(ary); return 0; }
void options()//show the options { int user_choice; clear_screen(); fflush(stdin); printf("Welcome to Film Genie version 1.0\r\n"); printf("Please input a number for the option\r\n"); printf("1.Play Film Genie\r\n"); printf("2.Help\r\n"); printf("3.Author\r\n"); printf("4.Exit\r\n"); scanf("%d",&user_choice); dummy=getchar(); if(user_choice==1){read_file();} if(user_choice==2){help();} if(user_choice==3){author();} if(user_choice==4){end_all();} if(user_choice==5){read_out();}//mainly for diagnostics on the file else {printf("Please try again with a number specified\r\n");wait_for_user();options();} }
pulsesequence() { get_parameters(); check_parameters(); set_powers(); calc_gradients(); if(!strcmp(bptype,"slice")) { slice_timing(); } else if(!strcmp(bptype,"noslice")) { noslice_timing(); } status(A); if (!strcmp(prep,"sr")) { saturation_pulse(); } else if (!strcmp(prep,"ir")) { inversion_pulse(); } else if (!strcmp(prep,"aps")) { aps_pulse(); } else if (!strcmp(prep,"t1r")) { spinlock_pulse(); } else { delay(tr-te-p1/2.0); } if(!strcmp(bptype,"slice")) { slice_offset(); status(B); selective_90(); slice_compensate(); delay(dx); selective_180(); delay(dy); read_out(); } else if(!strcmp(bptype,"noslice")) { status(B); bp_noslice(); } }
int main(int argc, char **argv) { int status = 0; int child_pid = 0; int child_count = 0; int read_count = 0; int write_count = 0; int empty = 0; int full = 0; void *shm_addr = NULL; int shm_id = 0; int sem_id = 0; shm_id = safe_shmget(); sem_id = safe_semget(); while ( child_count < 5 ) { child_pid = fork(); if ( child_pid < 0 ) // error { perror("fork"); exit(-1); } else if ( child_pid == 0 ) // child { shm_id = safe_shmget(); sem_id = safe_semget(); struct buffer msg; shm_addr = shmat(shm_id, NULL, 0); if ( shm_addr == ( (void *) -1 )) { perror("shmat"); exit(-1); } if ( child_count < 2 ) // producer { while( write_count < 6 ) { if(is_full(shm_addr)) { simple_sleep(); continue; } p(sem_id); fprintf(stdout, "child %d get into critical with empty count:%d\n", child_count, get_empty(shm_addr)); report(shm_addr); do { if(is_full(shm_addr)) { break; } bzero(&msg, sizeof(msg)); snprintf((char *)msg.msg, 128, "child %d is putting msg %d\n", child_count, write_count); fprintf(stdout, "%s", msg.msg); put_in(shm_addr, &msg); write_count++; }while(0); report(shm_addr); fprintf(stdout, "child %d get out of critical with empty count:%d\n", child_count, get_empty(shm_addr)); v(sem_id); } } else // consumer { while ( read_count < 4 ) { if ( is_empty(shm_addr) ) { simple_sleep(); continue; } p(sem_id); fprintf(stdout, "child %d get into critical with empty count:%d\n", child_count, get_empty(shm_addr)); report(shm_addr); do { if ( is_empty(shm_addr) ) { break; } bzero(&msg, sizeof(msg)); read_out(shm_addr, &msg); fprintf(stdout, "child %d read out msg: %s\n", child_count, msg.msg); read_count++; }while(0); report(shm_addr); fprintf(stdout, "child %d get out of critical with empty count:%d\n", child_count, get_empty(shm_addr)); v(sem_id); } } exit(0); } else //parent { child_count = child_count + 1; continue; } } for ( child_count=0; child_count<5; child_count++ ) { wait(); } safe_shmdel(shm_id); safe_semdel(sem_id); return 0; }