版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/Lichengguang_std/article/details/81558989
在对整数进行字符分割操作时,最关键的两个函数即为取整、取余;
floor、%;
此外,在编译时,头文件注意还要包括#include<cmath>,在进行判断语句时,注意是“==”而不是"=",否则会造成无输出;
#include<iostream>
#include<cmath>
using namespace std;
int main(){
int a;
cin >> a;
int c[10] = { 0 };
int ys,i;
while (a!=0){
ys = a % 10;
if (c[ys] == 0){
c[ys] = 1;
cout << ys;
}
a = floor(a / 10);
}
return 0;
}