#include<iostream>
#include<algorithm>
using namespace std;
bool cmp(char a, char b)
{
return a > b;
}
int main()
{
string a;
while(cin >> a)
{
sort(a.begin(), a.end(), cmp);
cout << a << endl;
}
return 0;
}
附录二: JAVA大数进制转换
import java.util.*;
import java.math.*;
public class Main
{
public static void main(String[] args)
{
Scanner input = new Scanner(System.in);
BigInteger M, N;
String number;
M = input.nextBigInteger();
N = input.nextBigInteger();
number = input.next();
//*************************//
number = number.toLowerCase();
//*************************//
BigInteger D = new BigInteger("0");
for(int i=0; i<number.length(); i++)
{
int x;
//*************************//
if(number.charAt(i) >= '0' && number.charAt(i) <= '9')
//*************************//
x = number.charAt(i) - '0';
else
x = number.charAt(i) - 'a' + 10;
D = D.multiply(M).add(new BigInteger(String.valueOf(x)));
}
String ans = "";
while(D.compareTo(new BigInteger("0")) != 0)
{
int x = D.mod(N).intValue();
if(x >= 10)
ans = (char)(x-10+'a') + ans;
else
ans = (char)(x+'0') + ans;
D = D.divide(N);
}
if(ans.length() == 0)
ans = "0";
System.out.println(ans);
input.close();
}
}
附录三:Java高精度浮点数求和
import java.util.*;
import java.math.*;
public class Main
{
public static void main(String[] args)
{
Scanner input = new Scanner(System.in);
BigDecimal a, b;
while(input.hasNext())
{
a = input.nextBigDecimal();
b = input.nextBigDecimal();
System.out.println(a.add(b));
}
input.close();
}
}
附录四:Java大数类排序
import java.util.*;
import java.math.*;
public class Main
{
public static void main(String[] args)
{
Scanner input = new Scanner(System.in);
int n;
n = input.nextInt();
BigInteger[] a = new BigInteger[n];
for(int i=0; i<n; i++)
{
a[i] = input.nextBigInteger();
}
Arrays.sort(a);
for(int i=0; i<n; i++)
System.out.println(a[i]);
input.close();
}
}