Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdio.h>
- int readarr(FILE* fin, int* data, int cnt);
- int readarr(FILE* fin, int* data, int cnt)
- {
- for (int k = 0; k < cnt; k++)
- {
- if (fscanf(fin, "%d", data + k) != 1){
- return -1;
- }
- }
- return 0;
- }
- void PrintArray(FILE* fout, int* data, int count);
- void PrintArray(FILE* fout, int* data, int count) {
- for (int k = 0; k < count; k++)
- fprintf(fout, "%d ", data[k]);
- }
- int bubble_sort(int N, int* array);
- int bubble_sort(N, array)
- {
- int tmp;
- int noSwap;
- for (int i = N - 1; i >= 0; i--)
- {
- noSwap = 1;
- for (int j = 0; j < i; j++)
- {
- if (array[j] > array[j + 1])
- {
- tmp = array[j];
- array[j] = array[j + 1];
- array[j + 1] = tmp;
- noSwap = 0;
- }
- }
- if (noSwap == 1)
- break;
- }
- return 0;
- }
- int main(void)
- {
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement