Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Program
- {
- static void Main(string[] args)
- {
- int[] a = {20,24,235,269,298,457,11,15,5555,8789,45,03,8987,444,44,005,04,02,877897,545454 };
- int[] c = new int[a.Length];
- int d = a.Max();
- int t =10;
- int u = 10;
- while (d != 0)
- {
- d= d / 10;
- t=t*10 ;
- }
- while (u <= t)
- {
- int x, y;
- for (int i = 0; i < a.Length; i++)
- {
- c[i] = a[i] % u;
- }
- for (int k = 0; k < a.Length; k++)
- {
- for (int j = 0; j < a.Length; j++)
- {
- if (c[k] <= c[j])
- {
- x = c[k];
- c[k] = c[j];
- c[j] = x;
- }
- }
- }
- for (int l = 0; l < a.Length; l++)
- {
- for (int m = 0; m < a.Length; m++)
- {
- if ((a[l] % u) == c[m])
- {
- y = c[m];
- c[m] = a[l];
- a[l] = y;
- }
- }
- }
- int e = 0;
- foreach (int item in c)
- {
- a[e] = item;
- e++;
- }
- u = u * 10;
- }
- foreach (int item in a)
- {
- Console.WriteLine(item);
- }
- }
- }
Add Comment
Please, Sign In to add comment