题解 | 提取不重复的整数

提取不重复的整数

https://www.nowcoder.com/practice/253986e66d114d378ae8de2e6c4577c1

#include <stdio.h>

int main() {
  char str[10];
  scanf("%s",str);
  char*p=str;
  while(*p!='\0'){
    p++;
  }p--;
  char str2[10];int i=0,flag=0;
  str2[0]=*p;
  for(;p>=str;p--){
    for(int temp=0;temp<i+1;temp++){
        if(str2[temp]==*p){
            flag++;
        }
    }
    if(!flag){
        str2[++i]=*p;
    }flag=0;
    if(p==str){
        break;//防止指针越界
    }
  }
  printf("%s",str2);



    return 0;
}

全部评论

相关推荐

评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务