Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <math.h>
- #include <string.h>
- #include <stdlib.h>
- #include <ctype.h>
- #include <time.h>
- void SelectionSort(int ar[300], int n)
- {
- int a, b, c, d, i, j, min;
- for (i = 0; i < n; i++)
- {
- min = ar[i];
- for (j = i + 1; j < n; j++)
- {
- if (ar[j] < min)
- {
- d = j;
- min = ar[j];
- }
- }
- ar[d] = ar[i];
- ar[i] = min;
- }
- }
- int main()
- {
- int t, i = 0, j, k, l, a, b, c, d, x, y, z, n, ar[300];
- char str[100];
- freopen("numbers.txt", "r", stdin);
- for (; ;)
- {
- gets(str);
- if (feof(stdin)) break;
- ar[i++] = atoi(str);
- }
- SelectionSort(ar, i);
- for (l = 0; l < i; l++) printf("%d\n", ar[l]);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement