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;
}
全部评论
大佬能说下是哪处代码问题么
点赞 回复 分享
发布于 2020-03-26 11:22
这个方法输入的整型中有0就不行吧
点赞 回复 分享
发布于 2020-03-25 14:34

相关推荐

哥_留个offer先:跟他说,你这个最好用c#,微软就用c#Java不适合这个项目
点赞 评论 收藏
分享
有担当的灰太狼又在摸鱼:零帧起手查看图片
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务