题目描述:
When an integer is inputted, the new integer is outputted from right to left and does not contain repeated digits.
- Example:
long GetConvertInt (long iInput)
Input: 9876673
Output: 37689
#include <stdlib.h>
#include "oj.h"
/*
功能:
输入:需要统计的长整型
输出:
返回:没有重复数字的整型
*/
//桶排序
long GetConvertInt( long iInput )
{
int integer_index[20] = {0};
int integer[20] = {0};
int cnt = 0;
while(iInput != 0)
{
integer_index[iInput%10]++;
if(integer_index[iInput%10] == 1)
{
integer[cnt] = iInput%10;
cnt++;
}
iInput /= 10;
}
for(int i = 0;i < cnt;i++)
{
iInput = iInput*10 + integer[i];
}
return iInput;
}