Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #define MAXLEN 1000 /* our limit on how many integers will go into an array */
- /* function declarations go here */
- void selection_sort(int A[], int n);
- void print_int_array(int A[], int n);
- int
- main() {
- int A[MAXLEN];
- int val; /* val is going to be the variable that scanf reads values into */
- int n; /* n is the number of elements read into the array */
- printf("Enter up to 1000 numbers: \n");
- while (scanf("%d",&val) == 1) {
- A[n] = val;
- n++;
- }
- /* call function on the array here */
- printf("Sorting ...\n");
- selection_sort(A, n);
- print_int_array(A, n); /* this will print the sorted array :o */
- return 0;
- }
- void print_int_array(int A[], int n) {
- int i;
- for (i=0; i<n; i++) {
- printf("%d ", A[i]);
- }
- printf("\n");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement