Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- struct Date {
- int Day, Month, Year;
- };
- int main() {
- int n;
- scanf("%d", &n);
- int b[10][n],k = 10,m = 1,h = 0,c;
- for (int j = 0;j < 10;j++)
- for(int i = 0;i < n;i++)
- b[j][i] = -1;
- struct Date a[n],d[n];
- for (int i = 0; i < n;i++){
- scanf("%d", &a[i].Year);
- scanf("%d", &a[i].Month);
- scanf("%d", &a[i].Day);
- }
- for (int j = 0; j < 2;j++) {
- int x = 0;
- for (int i = 0; i < n; i++) {
- h = 0;
- c = a[i].Day;
- while ((b[(c%k)/m][h] != -1) && (h < n))
- h++;
- if (h < n)
- b[(c%k)/m][h] = i;
- }
- for (int i = 0;i < 10;i++) {
- h = 0;
- while ((h < n) && (x < n)){
- if (b[i][h] != -1) {
- d[x] = a[b[i][h]];
- x++;
- }
- h++;
- }
- }
- for (int i = 0;i < n;i++)
- a[i] = d[i];
- for (int f = 0;f < 10;f++)
- for(int i = 0;i < n;i++)
- b[f][i] = -1;
- k *= 10;
- m *= 10;
- }
- k = 10;
- m = 1;
- for (int j = 0; j < 2;j++) {
- int x = 0;
- for (int i = 0; i < n; i++) {
- h = 0;
- c = a[i].Month;
- while ((b[(c%k)/m][h] != -1) && (h < n))
- h++;
- if (h < n)
- b[(c%k)/m][h] = i;
- }
- for (int i = 0;i < 10;i++) {
- h = 0;
- while ((h < n) && (x < n)){
- if (b[i][h] != -1) {
- d[x] = a[b[i][h]];
- x++;
- }
- h++;
- }
- }
- for (int i = 0;i < n;i++)
- a[i] = d[i];
- for (int f = 0;f < 10;f++)
- for(int i = 0;i < n;i++)
- b[f][i] = -1;
- k *= 10;
- m *= 10;
- }
- k = 10;
- m = 1;
- for (int j = 0; j < 4;j++) {
- int x = 0;
- for (int i = 0; i < n; i++) {
- h = 0;
- c = a[i].Year;
- while ((b[(c%k)/m][h] != -1) && (h < n))
- h++;
- if (h < n)
- b[(c%k)/m][h] = i;
- }
- for (int i = 0;i < 10;i++) {
- h = 0;
- while ((h < n) && (x < n)){
- if (b[i][h] != -1) {
- d[x] = a[b[i][h]];
- x++;
- }
- h++;
- }
- }
- for (int i = 0;i < n;i++)
- a[i] = d[i];
- for (int f = 0;f < 10;f++)
- for(int i = 0;i < n;i++)
- b[f][i] = -1;
- k *= 10;
- m *= 10;
- }
- for (int i = 0l;i < n;i++)
- printf("%d %d %d ", a[i].Year, a[i].Month, a[i].Day);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement