int FNodeBuilder::CreateNode (uint32_t set, unsigned int count, fixed_t bbox[4]) { node_t node; int skip, selstat; uint32_t splitseg; skip = int(count / MaxSegs); // When building GL nodes, count may not be an exact count of the number of segs // in the set. That's okay, because we just use it to get a skip count, so an // estimate is fine. if ((selstat = SelectSplitter (set, node, splitseg, skip, true)) > 0 || (skip > 0 && (selstat = SelectSplitter (set, node, splitseg, 1, true)) > 0) || (selstat < 0 && (SelectSplitter (set, node, splitseg, skip, false) > 0 || (skip > 0 && SelectSplitter (set, node, splitseg, 1, false)))) || CheckSubsector (set, node, splitseg)) { // Create a normal node uint32_t set1, set2; unsigned int count1, count2; SplitSegs (set, node, splitseg, set1, set2, count1, count2); D(PrintSet (1, set1)); D(Printf (PRINT_LOG, "(%d,%d) delta (%d,%d) from seg %d\n", node.x>>16, node.y>>16, node.dx>>16, node.dy>>16, splitseg)); D(PrintSet (2, set2)); node.intchildren[0] = CreateNode (set1, count1, node.nb_bbox[0]); node.intchildren[1] = CreateNode (set2, count2, node.nb_bbox[1]); bbox[BOXTOP] = MAX (node.nb_bbox[0][BOXTOP], node.nb_bbox[1][BOXTOP]); bbox[BOXBOTTOM] = MIN (node.nb_bbox[0][BOXBOTTOM], node.nb_bbox[1][BOXBOTTOM]); bbox[BOXLEFT] = MIN (node.nb_bbox[0][BOXLEFT], node.nb_bbox[1][BOXLEFT]); bbox[BOXRIGHT] = MAX (node.nb_bbox[0][BOXRIGHT], node.nb_bbox[1][BOXRIGHT]); return (int)Nodes.Push (node); }
bool Testit<1013>::Main() { DynArray<int> buf(10); int i=1; for(int &x : buf) x=i++; Printf(Con,"buf = #;\n",PrintSet(Range(buf))); for(int &x : Range(buf).part(3,5) ) x=i++; Printf(Con,"buf = #;\n",PrintSet(Range(buf))); return true; }
int main(void) { sigset_t set; sigset_t bset; sigemptyset(&set); sigaddset(&set, SIGINT); sigprocmask(SIG_BLOCK, &set, NULL); if (SIG_ERR == signal(SIGINT, IntHandler)) { perror("Install SIGINT error:\n"); } if (SIG_ERR == signal(SIGQUIT, QuitHandler)) { perror("Install SIGINT error:\n"); } BlockSignal(); while (1) { sigpending(&bset); PrintSet(&bset); sleep(2); } return 0; }
int main() { SetHeadPtr set_1 = CreateEmptySet(); AddElementToSet(set_1, CreateElement(10)); AddElementToSet(set_1, CreateElement(6)); AddElementToSet(set_1, CreateElement(2)); AddElementToSet(set_1, CreateElement(7)); AddElementToSet(set_1, CreateElement(9)); SetHeadPtr set_2 = CreateEmptySet(); AddElementToSet(set_2, CreateElement(9)); AddElementToSet(set_2, CreateElement(1)); AddElementToSet(set_2, CreateElement(2)); AddElementToSet(set_2, CreateElement(-5)); //SetHeadPtr set_1 = ReadSetFromFile("Set1.txt"); //SetHeadPtr set_2 = ReadSetFromFile("Set2.txt"); PrintSet(set_1); PrintSet(set_2); PrintSet(Union(set_1, set_2)); PrintSet(Intersections(set_1, set_2)); }
void print(P &out) const { Printf(out,"#;",PrintSet(Range(buf,len))); }
main (int argc, char *argv[]) { int done; int status; char buffer[256]; char responce[256]; char *bptr; char *cmdline; int buflen = 1; int firstentry = 1; int chars; char cmdchar; if (argc < 2) { fprintf(stdout,"usage: %s <devicename> (i.e. /dev/term/b)\n", argv[0]); exit(1); } verbose = 0; /* initialize Serial port to Gilson */ Portfd = initPort(argv[1],PATIENT_TABLE); /* need this info for isocenter calcualtions */ SoftLimits(); if (argc > 2) { cmdchar = argv[2][0]; /* printf("2nd arg: '%s'\n",argv[2]); */ if (cmdchar != '-') { status = 0; switch( toupper(cmdchar) ) { case 'M': MoveAxis(&(argv[2][1])); /* get status and clear up error bits */ Send_Cmd(statusCmd, responce); XYPos(X_AXIS); XYPos(Y_AXIS); break; case 'X': XYPos(X_AXIS); break; case 'Y': XYPos(Y_AXIS); break; case 'S': Status(); break; default: status = -1; break; } fflush(stdout); return(status); } else if (strcmp(argv[2],"-debug") == 0) { verbose = 1; } } if (verbose) fprintf(stdout,"Init Device: %s\n",argv[1]); if (verbose) PrintSet(); /* fprintf(stdout,"%lf %lf %lf %lf %lf %lf %lf %lf \n",xyMinMax[0],xyMinMax[1], xyMinMax[2],xyMinMax[3],xyMinMax[4],xyMinMax[5], MaxXYSpeed[0],MaxXYSpeed[1]); */ fflush(stdout); done = 1; while (done) { if (verbose) { fprintf(stdout,"M)ove Axis (MX+100,MY-100), S)tatus \n"); fprintf(stdout,"\nCmds: "); } else if (buflen) { if (!firstentry) fprintf(stdout,"Cmds:\n"); /* The GUI expects this prompt, verbatim */ else firstentry = 0; } /**********/ fflush(stdout); bptr = gets(buffer); buflen = strlen(buffer); if (bptr == NULL) break; switch( toupper(buffer[0]) ) { case 'M': MoveAxis(&buffer[1]); break; case 'S': Status(); break; case 'X': XYPos(X_AXIS); break; case 'Y': XYPos(Y_AXIS); break; case 'Q': done = 0; return; break; } } }
void show(const Type *ptr,ulen len) { Printf(Con,"#;\n",PrintSet(Range(ptr,len))); }
int main() { Set S1, S2, S3; unsigned int x,M,N,i,Univ; printf("Enter the Universal Space\n"); scanf("%d",&Univ); /********** Create Set S1 **********/ CreateSet(S1,Univ); printf("S1 set is \n"); PrintSet(S1,Univ); /********** Create Set S2 **********/ CreateSet(S2,Univ); printf("S2 set is \n"); PrintSet(S2,Univ); /* Create Set S3 *****************/ CreateSet(S3,Univ); printf("S3 set is \n"); PrintSet(S3,Univ); printf("Enter the number of Elements in S1 and S2\n"); scanf("%d%d",&M,&N); /********* Add Elements to S1 ******/ printf("Add Elements to S1\n"); for(i=0;i<M;i++) { printf("Enter the Element\n"); scanf("%d",&x); AddElementSet(x,S1,Univ); } printf("Add Elements to S2\n"); for(i=0;i<N;i++) { printf("Enter the Element\n"); scanf("%d",&x); AddElementSet(x,S2,Univ); } printf("The Set S1 after Addition\n"); PrintSet(S1,Univ); printf("The Set S2 after Addition\n"); PrintSet(S2,Univ); printf("Enter the Element to Delete from S1\n"); scanf("%d",&x); RemoveElementSet(x,S1,Univ); printf("The Set S1 after Removal\n"); PrintSet(S1,Univ); printf("Union of S1 and S2 sets are\n"); UnionSet(S1,S2,S3,Univ); PrintSet(S3,Univ); printf("Intersection of S1 and S2 sets are\n"); IntersectSet(S1,S2,S3,Univ); PrintSet(S3,Univ); printf("Complement of set S1 is\n"); ComplementSet(S1,S2,Univ); PrintSet(S2,Univ); printf("Is set S1 EQUALS set S2 ?\n"); if(EqualsSet(S1,S2,Univ)) printf("The Sets are EQUAL\n"); else printf("The Sets are NOT EQUAL\n"); printf("Enter the value for finding element\n"); scanf("%d",&x); if(isElementOfSet(x,S1,Univ)) printf("The value %d is AVAILABLE in S1\n",x); else printf("The value %d is NOT AVAILABLE in S1\n",x); return 0; }
static void AddExtensionFields (FGraph graph) { Node ptr; Arc arc; struct Ext *ext; int change; Set all; FreeExtensionFields (); if (graph->nodes == 0) return; if (graph->root == 0) Punt ("no root node"); all = 0; for (ptr = graph->nodes; ptr != 0; ptr = nextNode (ptr)) { nodeExt (ptr) = (others + n_others); others[n_others].dominator = 0; others[n_others].level = -1; others[n_others].order = n_others; all = Set_add (all, n_others); n_others += 1; } ext = (struct Ext *) nodeExt (graph->root); ext->level = 0; ext->dominator = Set_add (0, ext->order); for (ptr = graph->nodes; ptr != 0; ptr = nextNode (ptr)) { if (ptr == graph->root) continue; ext = (struct Ext *) nodeExt (ptr); ext->dominator = Set_union (0, all); } /* * compute dominators. */ change = 1; while (change != 0) { change = 0; for (ptr = graph->nodes; ptr != 0; ptr = nextNode (ptr)) { Set dom, temp; if (ptr == graph->root) continue; arc = sourceArcs (ptr); if (arc == 0) { dom = 0; } else { dom = Set_union (all, 0); for (; arc != 0; arc = nextArc (arc)) { ext = (struct Ext *) nodeExt (sourceNode (arc)); temp = Set_intersect (dom, ext->dominator); Set_dispose (dom); dom = temp; temp = 0; } ext = (struct Ext *) nodeExt (ptr); dom = Set_add (dom, ext->order); if (Set_same (dom, ext->dominator)) { Set_dispose (dom); } else { Set_dispose (ext->dominator); ext->dominator = dom; change += 1; } } } } all = Set_dispose (all); /* * compute level. */ change = 1; while (change != 0) { change = 0; for (ptr = graph->nodes; ptr != 0; ptr = nextNode (ptr)) { int max; ext = (struct Ext *) nodeExt (ptr); if (ext->level >= 0) continue; max = -1; for (arc = sourceArcs (ptr); arc != 0; arc = arc->next) { Node src; struct Ext *ex; src = sourceNode (arc); ex = (struct Ext *) nodeExt (src); /* ignore back-edges */ if (ex->order >= ext->order) continue; if (ex->level < 0) break; if (ex->level > max) max = ex->level; } if (arc == 0) { /* all source have been visited */ ext->level = max + 1; change += 1; } } } #ifdef DEBUG printf ("--------------------------------------------------\n"); for (ptr = graph->nodes; ptr != 0; ptr = nextNode (ptr)) { ext = nodeExt (ptr); printf ("# id=%d, order=%d, level=%d, ", ptr->id, ext->order, ext->level); PrintSet (stdout, "dominator", ext->dominator); } #endif }
main (int argc, char *argv[]) { int done; char buffer[256]; char msge[10]; char *bptr, *tmpptr; char Current_InjectValve_Loc; int CurrentXYmm[2],CurrentZmm,Current_AirValve_Loc,CurrentVol; int xAxis,yAxis; int i,maxflow; int sampZtop,sampZbottom; /* int xyzMinMax[6]; */ double flowrate, zspeed,ztravel; int buflen = 1; if (argc < 2) { fprintf(stdout, "usage: %s <devicename> (i.e. /dev/term/b)\n", argv[0]); exit(1); } if (argc > 2) { verbose = 0; } /* initialize environment parameter vnmrsystem value */ tmpptr = getenv("vnmrsystem"); /* vnmrsystem */ if (tmpptr != (char *) 0) { strcpy(systemdir,tmpptr); /* copy value into global */ } else { strcpy(systemdir,"/vnmr"); /* use /vnmr as default value */ } if (verbose) fprintf(stdout, "Init Default Injector 'm215_inj.grk' at 558.2, 3.8\n"); strcpy(path,systemdir); strcat(path,"/asm/racks/m215_inj.grk"); inject = rackCreate(path); if (inject == NULL) { fprintf(stderr, "\nSystem failed to init '%s'\n", path); fprintf(stderr,"\ngilalign Aborted.\n"); exit(1); } rackCenter(inject, 5582 ,38); /* 558.2, 3.8, 84.2 Gilson position */ if (verbose) rackShow(inject, 1); if (verbose) fprintf(stdout,"Init Default Rack 'code_205.grk' at 54.6, 187.2\n"); strcpy(path,systemdir); strcat(path,"/asm/racks/code_205.grk"); rack = rackCreate(path); if (rack == NULL) { fprintf(stderr,"\nSystem failed to init '%s'\n", path); fprintf(stderr,"\ngilalign Aborted.\n"); exit(1); } rackCenter(rack, 546,1872); if (verbose) rackShow(rack, 1); if (verbose) fprintf(stdout,"Init Device: %s\n",argv[1]); /* * Convert old style comm description to new style: * Old Style: /dev/term/a * New Style: GIL_TTYA */ if ( (!strcmp(argv[1], "/dev/term/a")) || (!strcmp(argv[1], "/dev/ttya")) ) pGilObjId = gilsonCreate("GIL_TTYA", 22, 29, 3); else if ( (!strcmp(argv[1], "/dev/term/b")) || (!strcmp(argv[1], "/dev/ttyb")) ) pGilObjId = gilsonCreate("GIL_TTYB", 22, 29, 3); else if (!strcmp(argv[1], "/dev/ttyS0")) pGilObjId = gilsonCreate("GIL_COM1", 22, 29, 3); else pGilObjId = gilsonCreate(argv[1], 22, 29, 3); if (pGilObjId == NULL) { fprintf(stderr,"\nFailure to initialize Gilson '%s'\n", argv[1]); fprintf(stderr,"\nCheck that the i/o cable is properly attached.\n"); fprintf(stderr,"\ngilalign Aborted.\n"); exit(1); } /* Initialize Rinse Station Location */ RinseStation[0] = pGilObjId->RinseStation[0]; RinseStation[1] = pGilObjId->RinseStation[1]; RinseStationZ = pGilObjId->RinseStation[2]; xAxis = rackGetX(inject, ZONE1,1); yAxis = rackGetY(inject, ZONE1,1); sampZtop = rackSampTop(inject,ZONE1,1); sampZbottom = rackSampBottom(inject,ZONE1,1); /* gilInitInjLoc(pGilObjId,xAxis, yAxis, bottom); */ gilInitInjLoc(pGilObjId,xAxis, yAxis, InjectorBot); MaxFlow = gilsonMaxFlowRate(pGilObjId); /* ml/min */ MaxVolume = gilsonMaxVolume(pGilObjId); /* ul */ gilGetContacts(pGilObjId, 2, &Current_AirValve_Loc); gilGetInjectValveLoc(pGilObjId,&Current_InjectValve_Loc); gilGetXY(pGilObjId,CurrentXYmm); gilGetZ(pGilObjId,&CurrentZmm); CurrentVol = gilsonCurrentVolume(pGilObjId); if (verbose) PrintSet(); done = 1; fprintf(stdout,"\n\n"); gilXYZMinMax(pGilObjId,xyzMinMax); /**********/ fprintf(stdout,"%d %d %d %d %d %d %d %lf %d %c %d %d %d %d\n", xyzMinMax[0],xyzMinMax[1], xyzMinMax[2],xyzMinMax[3], xyzMinMax[4],xyzMinMax[5], MaxVolume,MaxFlow, Current_AirValve_Loc,Current_InjectValve_Loc, CurrentXYmm[0],CurrentXYmm[1], CurrentZmm,CurrentVol); fflush(stdout); while (done) { if (verbose) { fprintf(stdout,"T)ray Alignment, R)inse Station Alignment, " "I)njector Alignment, \n"); fprintf(stdout,"N)ew Syringe, C) Set Injector/Rack Centers, " "L)ist Present Settings \n"); fprintf(stdout,"K - Reset&Home Gilson, V)alve, " "inJ)ector Valve, \n"); fprintf(stdout,"D)efine Rack, A)rm Hight, P)rime pump, " "S)ave Parameters, Q)uit, \n"); fprintf(stdout,"F)req Liq Detect X)GoToHome " "Z)Test Rack Definition \n"); fprintf(stdout,"O)utputs - sets Gilson contact states, " "E)xternal Inputs, Y) Transparent Mode \n"); fprintf(stdout,"\nCmds: "); } else if (buflen) { fprintf(stdout,"Cmds:\n"); } /**********/ fflush(stdout); bptr = gets(buffer); buflen = strlen(buffer); if (bptr == NULL) break; switch( toupper(buffer[0]) ) { case 'D': DefineRack(); break; case 'R': RinseAlignment(); break; case 'I': InjectAlignment(); break; case 'T': TrayAlignment(); break; case 'N': PumpReplace(); break; case 'C': /* set rack centers */ setCenters(); break; case 'L': PrintSet(); break; case 'O': setOutputs(); break; case 'E': getInputs(); break; case 'P': PrimePump(); break; case 'V': setValve(); break; case 'J': setInjector(); break; case 'K': gilsonReset(pGilObjId); gilsonHome(pGilObjId); break; /* * case 'B': * saveAlignments(); * break; */ case 'A': setArmHeight(); break; case 'Q': done = 0; gilsonDelete(pGilObjId); return; break; case 'S': /* Store alignment parameters */ SaveParameter(); break; case 'X': /* Move to Home Position */ gotoHome(); break; case 'F': chkLQZ(); break; case 'Y': GilsonTransparentMode(); break; case 'Z': chkRack(); break; } } }
int main() { LoadDict(&M); system("clear"); printf("%s=====================================================================\n", cyan); printf(" _ ______ ____ ____ ___ __ __________ ________ ____ \n"); printf("| | / / __ \\/ __ \\/ __ \\/ | / |/ / ____/ | / /_ __/ / __ \\ \n"); printf("| | /| / / / / / /_/ / / / / /| | / /|_/ / __/ / |/ / / / / / / /\n"); printf("| |/ |/ / /_/ / _ _ / /_/ / ___ |/ / / / /___/ /| / / / / /_/ / \n"); printf("|__/|__/\\____/_/ |_/_____/_/ |_/_/ /_/_____/_/ |_/ /_/ \\____/ \n\n"); printf("=====================================================================\n\n\n"); printf(" %sPress any key to continue%s\n",magenta,normal); getch(); while(opt1 != 5) //OPT1 = 5 adalah QUIT { MainMenu(&opt1); // MENAMPILKAN MAIN MENU switch(opt1) { case 1 : // REGISTER printf("%sEnter user name : ", cyan); do { found = false; // INISIALISASI YANG MENANDAKAN USER BELUM DITEMUKAN DI FILE EKSTERNAL scanf("%s", username.TabKata); username.Length = strlen(username.TabKata); if(strlen(username.TabKata) >= 20 || !(IsAlNumS(username))) // MENGECEK APAKAH LEBIH DARI 20 ATAU ALFANUMERIK printf("Username must be alphanumeric / less or equal to 20 characters\n"); else { *x = "scores/List Users & Highscores 2.txt"; STARTKATA(); while(!EndKata && !found) CheckUser(username,&id,&found); if(found) printf("Sorry, that username already exists\n"); } }while((strlen(username.TabKata) >= 20 || !(IsAlNumS(username))) || found); SalinFile(LU,username); printf("Congratulations! %s has been successfully registered\n",username.TabKata); printf("\n"); printf("%sPress any key to continue%s\n", magenta,cyan); dummygetch = getch(); dummygetch = getch(); break; case 2 : //LOGIN CreateList(&LU); printf("\n"); *x = "scores/List Users & Highscores 2.txt"; STARTKATA(); while(!(EndKata)) InitUser(&LU,&id); // MEMASUKKAN DATA FILE EKSTERNAL KE DALAM LIST InversListU(&LU); ListUsersLengkap(LU); // MENAMPILKAN LIST USER found1 = false; // INISIALISASI YANG MENANDAKAN USERNAME TIDAK DITEMUKAN while(!found1) { printf("=====================================================================\n"); printf("Enter username : "******"%s",username1.TabKata); username1.Length = strlen(username1.TabKata); STARTKATA(); while(!EndKata && !found1) CheckUser(username1,&id,&found1); if(!found1) printf("%s not found. Try again\n",username1.TabKata); } SelectB = true; // INISIALISASI AGAR SETELAH MEMILIH BOARD, MELIHAT SCORE TIDAK KELUAR KE MAIN MENU, MELAINKAN PREP MENU selectT = false; // INISIALISASI YANG MENANDAKAN USER BELUM PILIH BOARD while(SelectB == true) { if(selectT == false) kode = 1; PrepMenu(&opt2, username1); // PREPARATION MENU switch(opt2) { case 1 : // PLAY GAME if(selectT == false) { kode = 1; *y = "boards/1.txt"; } baris = 1; kolom = 1; T = false; used = false; score = 0; CreateEmptyQ(&QFinish); CreateEmpty(&S); CreateListSU(&LSG); CreateListSU(&LSGTemp); ReadSuggestion(&LSG, kode); strcpy(tempsugg, username1.TabKata); PSU = FirstSU(LSG); usersuggfound = false; while (PSU != Nil) { if (strcmp(InfoSU(PSU), tempsugg) == 0) { usersuggfound = true; break; } else { PSU = NextSU(PSU); } } if (!usersuggfound) { InsVSUFirst(&LSG, tempsugg); PSU = FirstSU(LSG); } InsVSUFirst(&LSGTemp, tempsugg); PSE = FirstSE(PSU); if (PSE != Nil) strcpy(tempsugg, InfoSE(PSE)); else { tempsugg[0] = ' '; tempsugg[1] = '\0'; } CreateListSet(&LS); CreateBoard(&B); AmbilBoard(&B); InitKursor(&B); InitSelect(&B, &S); system("clear"); printf("Score = %d\n\n", score); printf("Suggestion = %s\n\n", InfoSE(PSE)); TulisBoard(B); printf("\n\n"); dummygetch = getch(); input = getch(); printf("\n"); while (input != 'm') { system("clear"); ProsesKursor(&B, &baris, &kolom, &T, input, &error); Select(&B, baris, kolom, T, &S, &score, &LS, &QFinish, &used, &LSG, &LSGTemp, &M, PSU); printf("Score = %d\n\n", score); PSE = FirstSE(PSU); printf("Suggestion = %s\n\n", InfoSE(PSE)); TulisBoard(B); printf("\n"); if (used) printf("Invalid Word\n"); else printf("\n"); if (error) printf("error\n"); else printf("\n"); input = getch(); printf("\n"); error = false; used = false; } time(&rawtime); //INISIALISASI WAKTU t = localtime(&rawtime); D.YY = (*t).tm_year+1900; D.MM = (*t).tm_mon+1; D.DD = (*t).tm_mday; J.HH = (*t).tm_hour; J.MM = (*t).tm_min; J.SS = (*t).tm_sec; InsSortScoreU (&LU,D,J,score,username1); //INSERT SCORE KE LIST SCORE SalinInto(LU, kode); // MENYALIN KE FILE EKSTERNAL SelectB = false; system("clear"); addressQ PQ; PQ = Head(QFinish); while (PQ != Nil) { PrintSet(InfoQ(PQ)); printf("\n"); PQ = NextQ(PQ); } printf("Total Score = %d\n", score); PSU = FirstSU(LSG); PSE = FirstSE(PSU); PSUT = FirstSU(LSGTemp); while (PSUT != Nil) { PSET = FirstSE(PSUT); while (PSET != Nil) { InsVSEFirst(&LSG, PSU, InfoSE(PSET)); PSET = NextSE(PSET); } PSUT = NextSU(PSUT); } WriteSuggestion(LSG, kode); printf("Press any key to continue\n"); dummygetch = getch(); getch(); break; case 2 : //SELECT BOARD PilihBoard(&selectT, &kode); CreateList(&LU); STARTKATA(); while(!(EndKata)) InitUser(&LU,&id); // MEMASUKKAN DATA FILE EKSTERNAL KE DALAM LIST InversListU(&LU); SelectB = true; break; case 3 : //VIEW MY HIGH SCORES ViewMyHighScores(LU,username1); printf("%sPress any key to continue%s\n", magenta,cyan); dummygetch = getch(); dummygetch = getch(); SelectB = true; break; case 4 : //VIEW ALL HIGH SCORES ViewAllHighScores(LU); printf("%sPress any key to continue%s\n", magenta,cyan); dummygetch = getch(); dummygetch = getch(); SelectB = true; break; case 5 : //VIEW BOARD STATISTICS CreateEmptyQS(&QS); countuser = 0; countscore = 0; sumscore = 0; PU = FirstU(LU); while (PU != Nil) { PS = FirstS(PU); if((InfoD(PS)).YY != 0) { countuser += 1; } while(PS != Nil) { if((InfoD(PS)).YY != 0) { countscore += 1; sumscore += InfoS(PS); } PS = NextS(PS); } PU = NextU(PU); } //CreateList(&LU); averagescore = sumscore/countscore; printf("%.0f user/s have played in board %d\n",countuser,kode); if(countscore == 0) averagescore = 0; printf("The average score in board %d is %.2f\n",kode,averagescore); AddQS(&QS,kode,averagescore); for(i=0; i<=9;i++) { switch(i) { case 0 : *x = "scores/List Users & Highscores 1.txt"; break; case 1 : *x = "scores/List Users & Highscores 2.txt"; break; case 2 : *x = "scores/List Users & Highscores 3.txt"; break; case 3 : *x = "scores/List Users & Highscores 4.txt"; break; case 4 : *x = "scores/List Users & Highscores 5.txt"; break; case 5 : *x = "scores/List Users & Highscores 6.txt"; break; case 6 : *x = "scores/List Users & Highscores 7.txt"; break; case 7 : *x = "scores/List Users & Highscores 8.txt"; break; case 8 : *x = "scores/List Users & Highscores 9.txt"; break; case 9 : *x = "scores/List Users & Highscores 10.txt"; break; } if(i != kode) { CreateList(&LP); STARTKATA(); while(!EndKata) InitUser(&LP,&id); InversListU(&LP); sumscore = 0; countscore = 0; PX = FirstU(LP); while (PX != Nil) { PZ = FirstS(PX); while(PZ != Nil) { if((InfoD(PZ)).YY != 0) { countscore += 1; sumscore += InfoS(PZ); } PZ = NextS(PZ); } PX = NextU(PX); } if (countscore == 0) averagescore = 0; else averagescore = sumscore/countscore; AddQS(&QS, i, averagescore); } } PX = FirstU(LP); DealokasiU(&PX); PZ = FirstS(PX); DealokasiS(&PZ); P = Head(QS); printf("Difficulty Level of Boards : \n"); for(i=1;i<=10;i++) { printf("%d. Board no.%d with average user scores of %.2f\n",i,InfoQ(P),Prio(P)); P = NextQ(P); if (P == Nil) { break; } } printf("%sPress any key to continue%s\n", magenta,cyan); dummygetch = getch(); dummygetch = getch(); SelectB = true; break; case 6 : // LOG OUT SelectB = false; break; } if(SelectB == false) break; } break; case 3 : // HOW TO PLAY HowToPlay(); break; case 4 : // ABOUT About(); break; } } printf("%s\n", normal); //MENGGANTI WARNA TEXT TERMINAL KE AWAL return 0; }