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;
}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s