题解 | 提取不重复的整数
提取不重复的整数
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;
}
查看5道真题和解析