-
-
Save minhkhoablieu/651ba0e6dc94a6c0286dbbcd2d9c5a17 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
// 10 63 15 1 12 | |
// 0 0 0 0 0 | |
void Sort(int *A[100][100], int n) | |
{ | |
} | |
void moduloSort(char *filename) | |
{ | |
FILE *f = fopen(filename, "r"); | |
int n, mo; | |
fscanf(f, "%d %d", &n, &mo); | |
printf("%d %d", n, mo); | |
int A[n][2]; | |
for(int i = 0; i < n; i++) | |
{ | |
fscanf(f, "%d", &A[i][0]); | |
A[i][1] = A[i][0] % mo; | |
} | |
for (int i = 0; i < n-1; i++) | |
{ | |
for (int j = 0; j < n-i-1; j++) | |
{ | |
if(A[j][1] > A[j+1][1]) | |
{ | |
int B[1][1]; | |
B[0][0] = A[j][0]; | |
A[j][0] = A[j+1][0]; | |
A[j+1][0] = B[0][0]; | |
} | |
} | |
} | |
printf("\n"); | |
for(int i = 0; i < n; i++) | |
{ | |
printf("%d ", A[i][0]); | |
} | |
} | |
int main() | |
{ | |
moduloSort("data.inp"); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment