From 71d4187657bd06f03a6111f66e9f2dd4ec7d1712 Mon Sep 17 00:00:00 2001 From: Fudgerboy <91767657+Fudgerboy@users.noreply.github.com> Date: Sat, 17 Feb 2024 23:27:18 +0000 Subject: Sat, Feb 17, 2024, 3:27 PM -08:00 --- wk3/lab/selection.c | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) (limited to 'wk3/lab') diff --git a/wk3/lab/selection.c b/wk3/lab/selection.c index 056eaaf..93e1cc7 100644 --- a/wk3/lab/selection.c +++ b/wk3/lab/selection.c @@ -5,5 +5,28 @@ #include int main(void) { - + int arr[] = + for (int i = 0; i < arr.length - 1; i++) { + int n; + int m; + for (int j = i; j < arr.length - 1; j++) { + if (arr[j] < n || n === undefined) { + n = arr[j]; + m = j; + } + } + int k = arr[i]; + arr[i] = n; + arr[m] = k; + } } + + +/* + grab the first value and record it + go throught each value and record the smallest + swap the 1st value and the smallest value + repeat + + +*/ -- cgit v1.2.3