cpp #int转string用string的+合成最后输出,注意处理多组测试用例,!temp%10的位置顺序
提取不重复的整数
http://www.nowcoder.com/questionTerminal/253986e66d114d378ae8de2e6c4577c1
#include<iostream>
#include<string>
using namespace std;
int main()
{
int arr[11];
int a;
string str;
int temp=0;
while(cin>>a)
{
for(int i=0;i<11;i++)
{
arr[i]=-1;
}
temp=a%10;
while(temp!=0)
{
if(arr[temp]==-1)//第一次出现
{
arr[temp]=1;
str+=to_string(temp);
}
a=a/10;
temp=a%10;
}
cout<<str<<endl;
}
return 0;
}
查看7道真题和解析