编辑代码

#include <iostream>
using namespace std;
int main() {
    int x,a;
    int i;
    int str[10];
    do
    {cout<<"请输入一个小于1000的正整数:"<<endl;
cin>>x;}while(x<0);

//判断是几位数
if(x<10)
{cout<<"个位数是:"<<x<<endl;}
if(x>=10&&x<100){
    cout<<"个位数是:"<<x%10<<"  "<<"十位数是:"<<x/10<<endl;
}
if(x>=100&&x<1000){
    cout<<"个位数是:"<<x%10<<"  "<<"十位数是:"<<x/10%10<<"  "<<"百位数是:"<<x/100<<endl;
}


	return 0;
}