来看,比如一个数768534,将它的各个数位上的数字依次输出,就是4 3 5 8 6 7。那么来看其实只要这样
768534/1%10=4
768534/10%10=3
768534/100%10=5
768534/1000%10=8
768534/10000%10=6
768534/100000%10=7
那么循环就好了
#include <iostream>
#include <string>
using namespace std;
int main()
{
int n = 768534;
while (n > 0)
{
int tem = n % 10;
cout << tem << " ";
n = n / 10;
}
system("pause");
return 0;
}