日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

TJU Problem 2857 Digit Sorting

發布時間:2024/4/14 编程问答 45 豆豆
生活随笔 收集整理的這篇文章主要介紹了 TJU Problem 2857 Digit Sorting 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

原題:

2857. ? Digit Sorting
Time Limit: 1.0 Seconds? ?Memory Limit: 65536K
Total Runs: 3234? ?Accepted Runs: 1704



Several players play a game. Each player chooses a certain number, writes it down (in decimal notation, without leading zeroes) and sorts the digits of the notation in non-decreasing order, obtaining another number. The player who receives the largest number wins.

You are given the list of numbers initially chosen by the players. Output the winner's resulting number.

?

Input

The first line of each test case contains an integer N (1 ≤ N ≤ 50), indicating the number of the players. Then N integers followed in the second line. Each number will be between 0 and 100000, inclusive.

The input is terminated with N = 0.

?

Output

Output one line for each test case, indicating the winner's resulting number.

?

Sample Input

6 1 10 100 1000 10000 100000 3 9638 8210 331 0

Sample Output

1 3689



Source:?TJU Team Selection Contest 2007 (1)

?

?

?

1 #include <iostream> 2 #include <algorithm> 3 #include <string.h> 4 using namespace std; 5 6 int num[55]; 7 int b[55]; 8 9 int main() { 10 int N; 11 memset(b, 0, sizeof(b)); 12 while (cin >> N && N != 0) { 13 for (int k = 0; k < N; k++) { 14 memset(num, 0, sizeof(num)); 15 int n, count = 0; cin >> n; 16 for (int i = 0; i < 10; i++) { 17 num[i] = n % 10; 18 n /= 10; count++; 19 if (n == 0) break; 20 } 21 sort(num, num + count); 22 //9for (int i = 0; i < count; i++) cout << "num["<<i<<"] "<<num[i]<<endl; 23 //memcpy(b, num, sizeof(b)); 24 //cout << "b["<<k<<"] "<<b[k] << endl; 25 for (int i = 0; i < count; i++) { 26 if (num[i] != 0) b[k] = b[k]*10 + num[i]; 27 } 28 //cout << "b["<<k<<"] "<<b[k] << endl; 29 } 30 sort(b, b + N); 31 cout << b[N - 1] << endl; 32 memset(b, 0, sizeof(b)); 33 } 34 return 0; 35 }

?

?

?

轉載于:https://www.cnblogs.com/QingHuan/p/4263791.html

總結

以上是生活随笔為你收集整理的TJU Problem 2857 Digit Sorting的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。