uva 10905 Children's Game
2013-11-12 08:36
246 查看
简单题目,排序应用。
#include <iostream> #include <string> #include <algorithm> using namespace std; string arr[60]; int cmp(const void *a, const void *b) { string *pa = (string*)a; string *pb = (string*)b; if(*pa+*pb > *pb+*pa) return 1; else if(*pa+*pb == *pb+*pa) return 0; else return -1; } int main(void) { int n, i; //freopen("input.dat", "r", stdin); while(cin>>n, n) { for(i=0; i<n; i++) cin >> arr[i]; qsort(arr, n, sizeof(string), cmp); for(i=n-1; i>=0; i--) cout << arr[i]; cout << endl; } return 0; }
相关文章推荐
- 简单的四则运算
- 数的奇偶性
- 1272 小希的迷宫
- 1272 小希的迷宫
- hdu 1250 大数相加并用数组储存
- 1.10055 - Hashmat the brave warrior
- 2.10071 - Back to High School Physics
- 3.458 - The Decoder
- 4.694 - The Collatz Sequence
- 6.494 - Kindergarten Counting Game
- 7.490 - Rotating Sentences
- 8.414 - Machined Surfaces
- 9.488 - Triangle Wave
- A.457 - Linear Cellular Automata
- B.489 - Hangman Judge
- C.445 - Marvelous Mazes
- 1.10494 - If We Were a Child Again
- 2.424 - Integer Inquiry
- 3.10250 - The Other Two Trees
- 5.465 - Overflow