Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdlib.h>
- #include <stdio.h>
- void del(int *array, int *size, int id) {
- char move = 0;
- for (int i = 0; i < *size; ++i) {
- if (i == id) move = 1;
- else if (move == 1) array[i - 1] = array[i];
- }
- if (move == 1) --*size;
- }
- int lc(int chisl)
- {
- return chisl % 10;
- }
- void swap(unsigned long long *x, unsigned long long *y)
- {
- unsigned long long promezh = *x;
- *x = *y;
- *y = promezh;
- }
- int sum(int chisl)
- {
- int sum = 0;
- while (chisl != 0)
- {
- sum += chisl % 10;
- chisl /= 10;
- }
- return sum;
- }
- int maxcifr(int chisl)
- {
- int max = 0;
- while (chisl != 0)
- {
- if (max <= chisl % 10)
- {
- max = chisl % 10;
- }
- chisl /= 10;
- }
- return max;
- }
- int main()
- {
- int N;
- scanf("%i", &N);
- unsigned long long a[N];
- for (int i = 0; i < N; ++i)
- {
- scanf("%llu", &a[i]);
- }
- for (int i = 0 ; i < N - 1; i++)
- {
- for (int k = 0 ; k < N - i - 1 ; k++)
- {
- if (sum(a[k]) < sum(a[k + 1]))
- {
- swap(&a[k], &a[k + 1]);
- }
- }
- }
- for (int i = 0; i < N; ++i)
- {
- printf("%llu ", a[i]);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement