321 字
2 分钟
IGCSE Computer Science - Paper 2 Sample Code (23/mj/2024)
这段代码可以通过Pseudocode Pro来测试运行。
// Question 9
// Input the number of gamesREPEAT OUTPUT "How many games have been played:" INPUT PlayedUNTIL Played <= 18
// Team namesFOR Index <- 1 TO 10 OUTPUT "Enter the name:" INPUT Teams[Inedx]
// Record the number of won, drawn and lost // (Include the validation) OUTPUT "Enter the number of won, drawn and lost:" INTPUT Won, Drawn, Lost WHILE Won + Drawn + Lost <> Played DO OUTPUT "Enter again:" INTPUT Won, Drawn, Lost ENDWHILE
// Save the date in to Results[] Results[Index, 1] <- Won Results[Index, 2] <- Drawn Results[Index, 3] <- Lost
// Calculate the total point Results[Index, 4] <- 3 * Won + 1 * DrawnNEXT Index
// Sort the array// (Bubble Sort)Flag <- TRUEWHILE Flag = TRUE DO Flag <- FALSE FOR Sort <- 1 TO 9 IF Result[Sort, 4] < Result[Sort + 1, 4] THEN
// Sawp two values TempString <- Teams[Sort] Temp1 <- Results[Sort, 1] Temp2 <- Results[Sort, 2] Temp3 <- Results[Sort, 3] Temp4 <- Results[Sort, 4] Teams[Sort] <- Teams[Sort + 1, 1] Results[Sort, 1] <- Results[Sort + 1, 1] Results[Sort, 2] <- Results[Sort + 1, 2] Results[Sort, 3] <- Results[Sort + 1, 3] Results[Sort, 4] <- Results[Sort + 1, 4] Teams[Sort + 1] <- TempString Results[Sort + 1, 1] <- Temp1 Results[Sort + 1, 2] <- Temp2 Results[Sort + 1, 3] <- Temp3 Results[Sort + 1, 4] <- Temp4
Flag <- TRUE ENDIF NEXT SortENDWHILE
// Count the number of teams with the highest pointsCount <- 1Finish <- TRUEREPEAT IF Result[Count, 4] = result[Count + 1, 4] THEN Count <- Count + 1 ELSE Finish <- True ENFIFUNTIL Finish = TRUE
// Output the resultFOR Index <- 1 to Count OUTPUT "Winning Team(s): ", Teams[Index]NEXT IndexOUTPUT "Winning Points: ", Results[1 , 4] IGCSE Computer Science - Paper 2 Sample Code (23/mj/2024)
https://thyrius.top/posts/cscca/0478-paper23-mj-2024-sample-code/