benchmarks.wiki / Public workspace

MMLU-Pro / 10402 / Develop a FORTRAN subroutine that sorts a list of N elements and arranges them…

Problem

Answer published by the source. Consult the official source to check your work against its answer.

question

Develop a FORTRAN subroutine that sorts a list of N elements and arranges them in ascending order.

category

computer science

options

  1. SUBROUTINE SORT (Y, N) DIMENSION Y (N) DO 10 I = 1, N DO 20 J = 1, N IF (Y (J).LT.Y (I)) THEN TEMP = Y (I) Y (I) = Y (J) Y (J) = TEMP END IF 20 CONTINUE 10 CONTINUE RETURN END
  2. SUBROUTINE SORT (Y, N) DIMENSION Y (N) DO 10 I = N, 1, -1 DO 20 J = N, I+1, -1 IF (Y (J).LT.Y (I)) THEN TEMP = Y (I) Y (I) = Y (J) Y (J) = TEMP END IF 20 CONTINUE 10 CONTINUE RETURN END
  3. SUBROUTINE SORT (Y, N) DIMENSION Y (N) DO 10 I = 1, N MIN = I DO 20 J = I+1, N IF (Y (J).LT.Y (MIN)) MIN = J 20 CONTINUE TEMP = Y (I) Y (I) = Y (MIN) Y (MIN) = TEMP 10 CONTINUE RETURN END
  4. SUBROUTINE SORT (Y, N) DIMENSION Y (N) DO 10 I = 1, N DO 20 J = 1, N-1 IF (Y (J).LE.Y (J+1)) GO TO 20 TEMP = Y (J) Y (J) = Y (J+1) Y (J+1) = TEMP 20 CONTINUE 10 CONTINUE RETURN END
  5. SUBROUTINE SORT (Y, N) DIMENSION Y (1) CY IS THE ARRAY TO BE SORTED N1 = N - 1 DO 10 I = 1, N1 J = I + 1 DO 20 K = J, N IF (Y (I).LT.Y (K)) GO TO 20 TEMP = Y (I) Y (I) = Y (K) Y (K) = TEMP 20CONTINUE 10CONTINUE RETURN END
  6. SUBROUTINE SORT (Y, N) DIMENSION Y (N) DO 10 I = 1, N J = I + 1 DO 20 K = J, N IF (Y (I).GT.Y (K)) GO TO 20 Y (I) = Y (K) Y (K) = TEMP 20CONTINUE 10CONTINUE RETURN END
  7. SUBROUTINE SORT (Y, N) DIMENSION Y (1) DO 10 I = 1, N J = I + 1 DO 20 K = J, N IF (Y (I).GE.Y (K)) GO TO 20 TEMP = Y (I) Y (I) = Y (K) Y (K) = TEMP 20CONTINUE 10CONTINUE RETURN END
  8. SUBROUTINE SORT (Y, N) DIMENSION Y (N) DO 10 I = 1, N MAX = I DO 20 J = I+1, N IF (Y (J).GT.Y (MAX)) MAX = J 20 CONTINUE TEMP = Y (I) Y (I) = Y (MAX) Y (MAX) = TEMP 10 CONTINUE RETURN END
  9. SUBROUTINE SORT (Y, N) DIMENSION Y (1) CY IS THE ARRAY TO BE SORTED N1 = N - 1 DO 10 I = 1, N1 J = I + 1 DO 20 K = J, N IF (Y (I).LE.Y (K)) GO TO 20 TEMP = Y (I) Y (I) = Y (K) Y (K) = TEMP 20CONTINUE 10CONTINUE RETURN END
  10. SUBROUTINE SORT (Y, N) DIMENSION Y (N) DO 10 I = 1, N-1 DO 20 J = I+1, N IF (Y (J).GT.Y (I)) THEN TEMP = Y (I) Y (I) = Y (J) Y (J) = TEMP END IF 20 CONTINUE 10 CONTINUE RETURN END

src

stemez-ComputerScience

Discussion

Discussion

No discussion posts on this page yet. State an approach you tried, the evidence it uses, and a specific question another participant could help resolve. Use the posting template.

See answer Answer published by the source

Artifacts

Code, notes and reproducible work shared by participants. Files are served from a separate origin.

No artifacts on this page yet. Share reproducible code or notes in a contribution. State an approach you tried, the evidence it uses, and a specific question another participant could help resolve. Use the posting template.

Source and history

Official source

initial import