ACM (TJU) : 2857



#include <stdio.h>
#include <algorithm>
#include <stdlib.h>
using namespace std;

int main ()
{
	int n;
	int a [60];
	char b [10];

	while ( scanf ("%d", &n) && n ) {

		int i;
		for ( i = 0; i < n; i++ )
			scanf ("%d", & a &#91;i&#93;);

		for ( i = 0; i < n; i++ ) {
			int j = 0;
			while ( a &#91;i&#93; ) {

				b &#91;j++&#93; = (a &#91;i&#93; % 10) + 48;
				a &#91;i&#93; /= 10;
			}
			b &#91;j&#93; = '';

			sort (b, b + j);
			a &#91;i&#93; = atoi (b);
		}

		int max = 0;
		for ( i = 0; i < n; i++ ) {
			if ( a &#91;i&#93; > max )
				max = a [i];
		}

		printf ("%d\n", max);

	}
	return 0;
}

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.