int main(void) { welcome(); help(); int choice; Scanf("%d", &choice, 0, 5); linklist head = NULL; while(1) { switch(choice) { case 1: // IMPORT head = Read_flight(); break; case 2: // SHOW show_all(head); break; case 3: // FIND find(head); break; case 4: // SORT sort(head); break; case 5: // GET HELP help(); break; case 0: // QUIT printf("Bye-bye!\n"); exit(0); default: break; } // swtich Scanf("%d", &choice, 0, 5); } return 0; }
void main(void) { int seg, data; char c; unsigned e=0x9000,i=0; InitLib(); Print("\r\nPlease Input a value writting to segment 0x9000 of Flash Member: "); Scanf("%d", &seg); FlashErase(e); while(i<65535) { FlashWrite(e, i, seg); Print("\r\nThe value %d is writting to offset %d of Flash Memory", seg, i); i++; seg++; if(i%100==0) { Print("\r\nPress q to quit or any key to continue..."); c=Getch(); if ((c=='q') || (c=='Q')) return; } } }
double Get_real() { double ret; Rp = (double *)malloc(sizeof(double)); Printf("Enter a real: "); Scanf("%lf", Rp); ret = *Rp; free(Rp); return ret; }
long int Get_integer() { long int ret; Ip = (long int *)malloc(sizeof(long int)); Printf("Enter an integer: "); Scanf("%ld", Ip); ret = *Ip; free(Ip); return ret; }
EXPORT void i_init_remap_and_rect_grid( RECT_GRID* r_grid) { double *L = r_grid->L, *U = r_grid->U; int i, dim = r_grid->dim; const char **dnm, **Dnm, **dirs; static const char *plural[3] = { "", "s", "s"}; prompt_for_remap(dim,&Remap); dnm = Remap.dnm; Dnm = Remap.Dnm; dirs = Remap.dirs; for (i = 0; i < dim; ++i) { screen("Enter the computational limits in the " "%s direction, %sL, %sU: ",dnm[i],Dnm[i],Dnm[i]); (void) Scanf("%f %f\n",L+i,U+i); if (U[i] <= L[i]) { screen("ERROR in i_init_remap_and_rect_grid(), " "invalid computational limits L[%d] = %g, U[%d] = %g\n", i,L[i],i,U[i]); clean_up(ERROR); } } screen("Enter the number%s of grid intervals of the\n\t",plural[dim-1]); screen("computational grid in the %s direction%s: ",dirs[dim-1], plural[dim-1]); for (i = 0; i < dim; ++i) { (void) Scanf("%d",&r_grid->gmax[i]); r_grid->h[i] = (U[i] - L[i]) / r_grid->gmax[i]; } (void) Scanf("\n"); /* Grab trailing newline */ /* Set Default values for subdomain specifications */ /* correct for scalar runs */ set_rect_grid(L,U,L,U,NOBUF,NOBUF,r_grid->gmax,dim,&Remap,r_grid); Remap.area = r_grid->Remap.area; } /*end i_init_remap_and_rect_grid*/
static int Create(rawaudio* p) { if (Scanf(String(p->Format.Format.Class,RAWAUDIO_FORMAT),T("acodec/0x%x"),&p->Type)!=1) return ERR_INVALID_PARAM; p->Format.Init = (fmtfunc)RawAudioInit; p->Format.Seek = (fmtseek)RawAudioSeek; p->Format.ReadPacket = (fmtreadpacket)ReadPacket; p->SeekTime = 1; // but don't want to return 0 p->VBR = 1; return ERR_NONE; }
int main(/*int argc, char* argv[]*/){ char selection; char filename[10]; //if(argc == 0){// si le programme est lancé sans un fichier on affiche le menu while(1){ afficherMenu(); selection = GetChar(); switch (selection){ case '1':// creation du fichier creerFichier(); break; case '2' :// ouverture d'un fichier existant Printf("Quel fichier voulez vous ouvrir ?\n",0); Scanf("%s",filename); ouvrirFichier(filename); break; case '3' : //on quitte l'application Printf("Au Revoir\n",0); Exit(0); break; default : // au cas ou on rentre une commande qui n'est pas dans le menu Printf("Commande non reconnu\n",0); Printf("Fonctionnement : my_notepad <FILE>...\n",0); break; } } return 0; /*}else{ // si le programme est lancé avec un fichier alors on l'affiche // si le fichier existe on l'ouvre if(ouvrirFichier(argv[1]) == -1){ creerFichier(argv[1]);//si le fichier n'existe pas on le crée et on l'ouvre. } }*/ //return 0; }
void main() { int input; int q,c,i; Printf("\n1 general interaction between two threads\n"); Printf("\n2 threads trying to work on lock that has not been created\n"); Printf("\n3 Broadcast all the waiting threads\n"); Printf("\n4 signal done by thread but no one waiting..\n"); Printf("\n5 many threads waiting.....but only one signal\n"); Printf("\n6 one thread waiting on some lock and other thread signals it on some other lock..\n"); Printf("\n7 lock number is greater than max locks spacei.e 100\n"); Printf("\n8 forking more than 100 threads in 1 proc..which is beyond the set limit ... so error\n"); Printf("\n9 Two execs..and it should call 2 process and in which 2 threads tries to acquire each other's lock..\n"); Printf("\n10 lock acquired by one thread so all other should wait for the thread to release the lock.. \n"); Printf("\n11 testing destroy lock and destroy CV system call \n"); Printf("\n12 running 2 carl jr proccesses with \nCUSTOMERS:30 \n OT:5\n COOKS:3\nWAITER:5\nMANAGER:1\n"); input= Scanf(); switch ( input) { case 1: q= Exec("../test/test1",13); break; case 2: q= Exec("../test/test2",13); break; case 3: q= Exec("../test/test3",13); break; case 4: q= Exec("../test/test4",13); break; case 5: q= Exec("../test/test5",13); break; case 6: q= Exec("../test/test6",13); break; case 7: q= Exec("../test/test7",13); break; case 8: q= Exec("../test/test8",13); break; case 9: q= Exec("../test/test9",13); c= Exec("../test/test10",14); Yield(); break; case 10: q= Exec("../test/test11",14); break; case 11: q= Exec("../test/test12",14); break; case 12: q= Exec("../test/carljr",14); c= Exec("../test/carljr",14); break; } for(i=0;i<10000;i++) { Yield(); } }
int main() { int size; /*will be used to take in user input for the sizes of specific variables*/ int senatorSize; int i; int j; int k; int l; int m; int n; int numberOfSenators; int testSuite; int numAppClerks; int numPicClerks; int numCashiers; int numPassportClerks; /*Uprintf("For TestSuite, enter 1\nFor Simulation, enter 2", 46, 0, 0, 0, 0); testSuite = Scanf();*/ testSuite = 0; if(testSuite == 1) testSuite = 0; /*TestSuite();*/ else { Uprintf("Number of ApplicationClerks = ", 30, 0, 0, 0, 0); size = Scanf(); numAppClerks = size; initialize(&appClerk, 0, size); Uprintf("Number of PictureClerks = ", 26, 0, 0, 0, 0); size = Scanf(); numPicClerks = size; initialize(&picClerk, 1, size); Uprintf("Number of PassportClerks = ", 27, 0, 0, 0, 0); size = Scanf(); numPassportClerks = size; initialize(&passPClerk, 2, size); Uprintf("Number of Cashiers = ", 21, 0, 0, 0, 0); size = Scanf(); numCashiers = size; initialize(&cashier, 3, size); Uprintf("Number of Customers = ", 22, 0, 0, 0, 0); size = Scanf(); Uprintf("Number of Senators = ", 21, 0, 0, 0, 0); numberOfSenators = Scanf(); size += numberOfSenators; /*SetMV(numCustomersLeft, 0, size);*/ /* Create global server MVs and initialize everything */ createServerMVs(size, numberOfSenators); /*initialize all the programs here*/ for(j = 0; j < size; j++) { Exec("../test/customer",16); } for(k = 0; k < numAppClerks; k++) { Exec("../test/appClerk",16); } for(l = 0; l < numPicClerks; l++) { Exec("../test/picClerk",16); } for(m = 0; m < numPassportClerks; m++) { Exec("../test/passPClerk",18); } for(n = 0; n < numCashiers; n++) { Exec("../test/cashier",15); } Exec("../test/manager",15); return; } }
EXPORT void g_prompt_for_composition_type( INIT_DATA *init) { int i; int dim = i_intfc(init)->dim; char s[Gets_BUF_SIZE]; static Prompt_type ctypes[] = { {"PURE_NON_REACTIVE","PNR",3,{PURE_NON_REACTIVE} }, #if defined(MULTI_COMPONENT) {"MULTI_COMP_NON_REACTIVE","MCNR",4,{MULTI_COMP_NON_REACTIVE}}, #endif /* defined(MULTI_COMPONENT) */ #if defined(COMBUSTION_CODE) {"PTFLAME","PTF",3,{PTFLAME}}, {"ZND","ZND",3,ZND}, {"TWO_CONSTITUENT_REACTIVE","TCR",3,{TWO_CONSTITUENT_REACTIVE}}, {"THINFLAME","THF",3,{THINFLAME}}, #endif /* defined(COMBUSTION_CODE) */ {NULL, NULL, 0, {ERROR} } }; material_composition_type(init) = PURE_NON_REACTIVE; screen("\nRequest composition type of materials. " "Available types are\n"); for (i = 0; ctypes[i].prompt != NULL; ++i) { screen("\t\t%s (%s",ctypes[i].prompt,ctypes[i].select); if (ctypes[i].type.itype == material_composition_type(init)) screen(", default"); screen(")\n"); } screen("\tEnter choice here: "); (void) Gets(s); if (s[0] != '\0') { for (i = 0; ctypes[i].prompt != NULL; ++i) { if (strncasecmp(s,ctypes[i].select,ctypes[i].ncmp) == 0) { material_composition_type(init) = ctypes[i].type.itype; break; } } } /* NOTE: NumberFloats(init) will be modified in g_compute_sizest() **/ if(MULTI_COMP_NON_REACTIVE == material_composition_type(init)) { (void) printf("Request for maximum number of composed materials: "); (void) Scanf("%d\n",&NumberFloats(init)); (void) printf("The maximum number of composed materials is %d\n", NumberFloats(init)); } g_compute_sizest(material_composition_type(init), &StateSize(init),&NumberFloats(init),dim); /* This change should be universal */ if(MULTI_COMP_NON_REACTIVE == material_composition_type(init)) { g_set_sizeof_state(NULL,StateSize(init),NumberFloats(init)); set_composition_type(material_composition_type(init)); } } /*end g_prompt_for_composition_type*/
int main() { int a, b, resultat; char c; char *s, *t; a = 0; b = 0; s = (char*) malloc(MAX_LENGTH * sizeof(char)); t = (char*) malloc(MAX_LENGTH * sizeof(char)); if (s == 0 || t == 0) { Printf("Erreur alloc\n"); return -1; } Printf("Veuillez entrer un entier svp ?\n"); resultat = Scanf("%d", &a); if (resultat) Printf("Erreur lecture\n\n"); else Printf("Entier entré : %d\n\n", a); Printf("Veuillez entrer un char svp ?\n"); resultat = Scanf("%c", &c); if (resultat) Printf("Erreur lecture\n\n"); else Printf("Char entré : %c\n\n", c); Printf("Veuillez entrer un string svp ?\n"); resultat = Scanf("%s", s); if (resultat) Printf("Erreur lecture\n\n"); else Printf("String entré : %s\n\n", s); Printf("Veuillez entrer un caractere puis deux entier svp ?\n"); resultat = Scanf("%c%d %i", &c, &b, &a); if (resultat) Printf("Erreur lecture\n\n"); else Printf("lu : %c %d %i\n\n", c, b, a); Printf("Veuillez entrer deux chaines svp ?\n"); resultat = Scanf("%s%s", s, t); if (resultat) Printf("Erreur lecture\n\n"); else Printf("lu : %s / %s \n\n", s, t); Printf("Test erreur :\n"); resultat = Scanf("%w", s); if (resultat) Printf("Erreur lecture\n\n"); else Printf("String entré : %s\n\n", s); //liberation des malloc free(s); free(t); return 0; }
LOCAL bool g_prompt_and_reset_for_cauchy_deposition( INIT_DATA *init, INIT_PHYSICS *ip, Wave *wave) { char axis[]={'t','x','y','z'}, s[Gets_BUF_SIZE]; int i, d, dim = wave->rect_grid->dim; Gas_param *new_param; Front *front = ip->root->front; INTERFACE *intfc = front->interf; debug_print("deposition","Entered g_cauchy_deposition()\n"); /* prompt for Cauchy deposition */ screen("Type \'y\' to set cauchy deposition: "); Gets(s); if (s[0] != 'Y' && s[0] != 'y') return NO; screen("Type \'y\' to change the eos for states: "); Gets(s); if (s[0] == 'Y' || s[0] == 'y') new_param = init_eos_params(init, ip, " ", YES); else new_param = NULL; screen("Enter the number of depositions (1 to %d): ",MAX_DEPOSITION_NUMBER); Scanf("%d\n", &dep_number); if (dep_number < 1 || dep_number > MAX_DEPOSITION_NUMBER) { screen("Illegal number of depositions.\n"); clean_up(ERROR); } for (i = 0; i < dep_number; i++) { screen("For deposition %d\n", i); screen("Enter the component number for the deposition: "); Scanf("%d\n",&deparam[i].comp); screen("Choose the deposition type from\n"); screen("\tEnergy(dflt), Pressure, Temperature, X-Velocity,\n"); screen("\tY-Velocity, Z-Velocity, Density\n"); screen("Enter the deposition type: "); Gets(s); if (s[0] == 'P' || s[0] == 'p') deparam[i].type = EXT_PRESSURE; else if (s[0] == 'T' || s[0] == 't') deparam[i].type = EXT_TEMPER; else if (s[0] == 'X' || s[0] == 'x') deparam[i].type = EXT_VX; else if (s[0] == 'Y' || s[0] == 'y') deparam[i].type = EXT_VY; else if (s[0] == 'Z' || s[0] == 'z') deparam[i].type = EXT_VZ; else if (s[0] == 'D' || s[0] == 'd') deparam[i].type = EXT_DENSITY; else deparam[i].type = EXT_ENERGY; printf("deparam[%d].type = %d\n",i,deparam[i].type); screen("Enter the base value of deposition: "); Scanf("%f\n",&deparam[i].base); screen("Enter the amplitude of deposition: "); Scanf("%f\n",&deparam[i].amp); screen("Enter the shape of deposition region (Rect or Ellip): "); Gets(s); if (s[0] == 'E' || s[0] == 'e') deparam[i].region = DEP_ELLIP; else deparam[i].region = DEP_RECT; for (d = 0; d < dim+1; d++) { screen("Along %c direction\n",axis[d]); if (d == 0 || deparam[i].region == DEP_RECT) { deparam[i].bd[d][0] = -HUGE_VAL; deparam[i].bd[d][1] = HUGE_VAL; screen("Enter the lower and upper boundary: "); } else { deparam[i].bd[d][0] = 0; deparam[i].bd[d][1] = HUGE_VAL; screen("Enter the center and radius: "); } Scanf("%f %f\n",deparam[i].bd[d],deparam[i].bd[d]+1); if (deparam[i].bd[d][0] == deparam[i].bd[d][1]) { deparam[i].prof[d] = CONSTANT_PROFILE; continue; // depo layer length[d] = 0: CONSTANT } screen("Choose deposition profile from\n"); screen("\tGaussian, Power, Sinusoidal, Constant(dflt)\n"); screen("Enter the deposition profile: "); Gets(s); if (s[0] == 'g' || s[0] == 'G') { deparam[i].prof[d] = GAUSSIAN; screen("Enter the origin of the profile: "); Scanf("%f\n",&deparam[i].orig[d]); screen("Enter the decay length: "); Scanf("%f\n",deparam[i].param[d]); screen("Enter if it is exponential decay: "); Gets(s); if (s[0] == 'y' || s[0] == 'Y') deparam[i].flag[d][0] = true; else deparam[i].flag[d][0] = false; } else if (s[0] == 'p' || s[0] == 'P') { deparam[i].prof[d] = POWER; screen("Enter the origin of the profile: "); Scanf("%f\n",&deparam[i].orig[d]); screen("Enter the decay exponent: "); Scanf("%f\n",deparam[i].param[d]); } else if (s[0] == 's' || s[0] == 'S') { deparam[i].prof[d] = SINUSOIDAL; screen("Enter the origin of the profile: "); Scanf("%f\n",&deparam[i].orig[d]); screen("Enter the period: "); Scanf("%f\n",deparam[i].param[d]); screen("Enter the phase at origin in degrees: "); Scanf("%f\n",deparam[i].param[d]+1); } else { deparam[i].prof[d] = CONSTANT_PROFILE; } } } if(new_param != NULL) change_states_param(front, wave, deparam[0].comp, new_param); debug_print("deposition","\nLeft g_cauchy_deposition()\n"); return YES; } /* end of set_ext_deposition */