int main() { //Scan files for tags FileScan(); //Tagging while (1) { //Process initial screen Screen_Initial(); //Process tagging screen Screen_Tagging(); } return 0; }
void main(){ char * SearchMsg[] = { "찾기성공", "삭제 등록된 데이터가 없습니다.", "찾으려는 데이터가 존재하지 않습니다." }; char * ChangeMsg[] = { "수정성공", "등록된 데이터가 없습니다.", "찾으려는 데이터가 존재하지 않습니다." }; char * DeleteMsg[] = { "삭제성공", "삭제 등록된 데이터가 없습니다.", "찾으려는 데이터가 존재하지 않습니다." }; ISBN * BookArray = {}; char mode = '1'; int TotalBook=10; int BookNum = 0; BookArray = (ISBN *)malloc(sizeof(ISBN)* 1); while (mode != '0'){ printf("\nmode 선택 ( 1 = 입력 , 2 = 출력 , 3 = 단일검색, 4 = 수정(정확한 이름), 5 = 단일삭제(정확한 이름), 6 = 파일저장, 7 = 파일로드 0 = 종료) \n"); mode = getchar(); fflush(stdin); switch (mode) { case '1': AddBook(BookArray, &BookNum, TotalBook); break; case '2': PrintBookList(BookArray, BookNum); break; case '3': SearchBook(BookArray, BookNum, SearchMsg); break; case '4': ChangeBook(BookArray, BookNum, SearchMsg, ChangeMsg); break; case '5': DeleteBook(BookArray, &BookNum, DeleteMsg); break; case '6': FilePrint(BookArray, TotalBook, BookNum); break; case '7': FileScan(BookArray, &TotalBook, &BookNum); break; default: mode = '0'; for (int i= 0; i < TotalBook;i++) KillData(&BookArray[i]); break; } } }
s32 FileSelect() { s8 text[SAL_MAX_PATH]; s8 previewPath[SAL_MAX_PATH]; s8 previousRom[SAL_MAX_PATH]; u16 romPreview[262 * 186]; bool8 havePreview = FALSE; s32 action=0; s32 smooth=0; u16 color=0; s32 i=0; s32 focus=ROM_SELECTOR_DEFAULT_FOCUS; s32 menuExit=0; s32 scanstart=0,scanend=0; u32 keys=0; s32 size=0, check=SAL_OK; previousRom[0] = '\0'; if (FileScan() != SAL_OK) { strcpy(mRomDir, sal_DirectoryGetUser()); if (FileScan() != SAL_OK) { MenuMessageBox("Home directory inaccessible","","",MENU_MESSAGE_BOX_MODE_PAUSE); mRomCount=ROM_SELECTOR_DEFAULT_FOCUS; menuExit = 1; return 0; } } focus = LoadLastSelectedRomPos(); //try to load a saved position in the romlist smooth=focus<<8; sal_InputIgnore(); while (menuExit==0) { keys=sal_InputPollRepeat(); if (keys & INP_BUTTON_MENU_SELECT) { switch(focus) { case ROM_SELECTOR_SAVE_DEFAULT_DIR: //Save default directory DelLastSelectedRomPos(); //delete any previously saved position in the romlist SaveMenuOptions(mSystemDir, DEFAULT_ROM_DIR_FILENAME, DEFAULT_ROM_DIR_EXT, mRomDir, strlen(mRomDir), 1); break; case ROM_SELECTOR_MAIN_MENU: //Return to menu action=0; menuExit=1; break; case ROM_SELECTOR_DEFAULT_FOCUS: //blank space - do nothing break; default: // normal file or dir selected if (mRomList[focus].type == SAL_FILE_TYPE_DIRECTORY) { //Check for special directory names "." and ".." if (sal_StringCompare(mRomList[focus].filename,".") == 0) { //goto root directory } else if (sal_StringCompare(mRomList[focus].filename,"..") == 0) { // up a directory //Remove a directory from RomPath and rescan //Code below will never let you go further up than \SD Card\ on the Gizmondo //This is by design. sal_DirectoryGetParent(mRomDir); FileScan(); focus=ROM_SELECTOR_DEFAULT_FOCUS; // default menu to non menu item // just to stop directory scan being started smooth=focus<<8; sal_InputIgnore(); break; } else { //go to sub directory sal_DirectoryCombine(mRomDir,mRomList[focus].filename); FileScan(); focus=ROM_SELECTOR_DEFAULT_FOCUS; // default menu to non menu item // just to stop directory scan being started smooth=focus<<8; } } else { // user has selected a rom, so load it SaveLastSelectedRomPos(focus); // save the current position in the romlist strcpy(mRomName, mRomDir); sal_DirectoryCombine(mRomName,mRomList[focus].filename); mQuickSavePresent=0; // reset any quick saves action=1; menuExit=1; } sal_InputIgnore(); break; } } else if (keys & INP_BUTTON_MENU_CANCEL) { sal_InputWaitForRelease(); action=0; menuExit=1; } else if ((keys & (SAL_INPUT_UP | SAL_INPUT_DOWN)) && (keys & (SAL_INPUT_UP | SAL_INPUT_DOWN)) != (SAL_INPUT_UP | SAL_INPUT_DOWN)) { if (keys & SAL_INPUT_UP) focus--; // Up else if (keys & SAL_INPUT_DOWN) focus++; // Down } else if ((keys & (SAL_INPUT_LEFT | SAL_INPUT_RIGHT)) && (keys & (SAL_INPUT_LEFT | SAL_INPUT_RIGHT)) != (SAL_INPUT_LEFT | SAL_INPUT_RIGHT)) { if (keys & SAL_INPUT_LEFT) focus-=12; else if (keys & SAL_INPUT_RIGHT) focus+=12; if (focus>mRomCount-1) focus=mRomCount-1; else if (focus<0) focus=0; smooth=(focus<<8)-1; } if (focus>mRomCount-1) { focus=0; smooth=(focus<<8)-1; } else if (focus<0) { focus=mRomCount-1; smooth=(focus<<8)-1; } // Draw screen: PrintTitle("ROM selection"); if (strcmp(mRomList[focus].displayName, previousRom) != 0) { char dummy[SAL_MAX_PATH], fileNameNoExt[SAL_MAX_PATH]; sal_DirectorySplitFilename(mRomList[focus].filename, dummy, fileNameNoExt, dummy); sprintf(previewPath, "%s/previews/%s.%s", sal_DirectoryGetHome(), fileNameNoExt, "png"); strcpy(previousRom, mRomList[focus].displayName); havePreview = sal_ImageLoad(previewPath, &romPreview, 262, 186) != SAL_ERROR; if (havePreview) { sal_VideoBitmapDim(romPreview, 262 * 186); } } if (havePreview) { sal_ImageDraw(romPreview, 262, 186, 0, 16); } smooth=smooth*7+(focus<<8); smooth>>=3; scanstart=focus-15; if (scanstart<0) scanstart=0; scanend = focus+15; if (scanend>mRomCount) scanend=mRomCount; for (i=scanstart;i<scanend;i++) { s32 x=0,y=0; y=(i<<4)-(smooth>>4); x=0; y+=112 - 28; if (y<=48 - 28 || y>=232 - 36) continue; if (i==focus) { color=SAL_RGB(31,31,31); PrintBar(y-4); } else { color=SAL_RGB(31,31,31); } // Draw Directory icon if current entry is a directory if(mRomList[i].type == SAL_FILE_TYPE_DIRECTORY) { sprintf(text,"<%s>",mRomList[i].displayName); sal_VideoPrint(x,y,text,color); } else { sal_VideoPrint(x,y,mRomList[i].displayName,color); } } sal_VideoPrint(0,4,mRomDir,SAL_RGB(31,8,8)); sal_VideoFlip(1); usleep(10000); } sal_InputIgnore(); freeRomLists(); return action; }
int main(int argc, char **argv) { LR_PARAM input_params; long int i,j, m, d; double *w, *Y, **X, precision, *h, Erreur, Precision, Rappel, F, PosPred, PosEffect, PosEffPred; char input_filename[200], params_filename[200]; srand(time(NULL)); // Reading the parameters line lire_commande(&input_params,input_filename, params_filename,argc, argv); // Scan of the training file // definition in utilitaire.c FileScan(input_filename,&m,&d); printf("Training set containing %ld examples in dimension %ld\n",m,d); Y = (double *) malloc((m+1)*sizeof(double )); X = (double **) malloc((m+1)*sizeof(double *)); if(!X){ printf("Memory allocation problem (1)\n"); exit(0); } X[1]=(double *)malloc((size_t)((m*d+1)*sizeof(double))); if(!X[1]){ printf("Memory allocation problem (2)\n"); exit(0); } for(i=2; i<=m; i++) X[i]=X[i-1]+d; w = (double *) malloc((d+1) * sizeof(double )); // Loading of the data matrix procedure defined in utilitaire.c ChrgMatrix(input_filename, m, d, X, Y); // Adaline algorithm adaline(X, Y, w, m, d, input_params.eta, input_params.T); h = (double *) malloc((m+1)*sizeof(double )); for(i=1; i<=m; i++) /*@$\rhd h_t(\mathbf{x}_i)\leftarrow w^{(t)}_0+\left\langle \boldsymbol w^{(t)},\mathbf{x}_i\right\rangle$@*/ for(h[i]=w[0], j=1; j<=d; j++) h[i]+=(w[j]*X[i][j]); for(i = 1, Erreur = 0.0; i <= m; ++i) { Erreur += (Y[i] - h[i]) * (Y[i] - h[i]); } Erreur /= (double)m; printf("Erreur=%lf\n", Erreur); /* for(i=1,PosPred=PosEffect=PosEffPred=Erreur=0.0; i<=m; i++){ if(Y[i]*h[i]<=0.0) Erreur+=1.0; if(Y[i]==1.0){ PosEffect++; if(h[i]>0.0) PosEffPred++; } if(h[i]>0.0) PosPred++; } Erreur/=(double)m; Precision=PosEffPred/PosPred; Rappel=PosEffPred/PosEffect; F=2.0*Precision*Rappel/(Precision+Rappel); printf("Precision:%lf Recall:%lf F1-measure:%lf Error=%lf\n",Precision,Rappel,F,Erreur); */ free((char *)h); save_params(params_filename, w,d); return 1; }