从键盘输入一个四位正整数。首先分离出该正整数的每一位数字,并按逆序输出各位数字

从键盘输入一个四位正整数。首先分离出该正整数的每一位数字,并按逆序输出各位数字;然后用分离出来的每位数字组成一个最大数和最小数,并输出 具体要求: 1)输入前有提示,并检查数据的合法性,若输入的数据不合法,则显示输出错误信息 2)对输出的结果要具体说明
#include<iostream>
using namespace std;
void main()
{
int num;
cout<<"input the data:"<<endl;
cin>>num;
if(num<1000||num>饥模9999)
do{
cout<者肢兄<"input wrong,try again!"<<endl;
cin>>num;
}while(num<1000||num>9999);
int temp=num,a[4],i=0;
cout<<"the reverse sorted is:"<<endl;
for(i=0;i<4;i++)
{
a[i]=temp%10;
temp/=10;
cout<<a[i];
}
cout<<endl;
for(i=0;i<4;i++)
for(int j=i+1;j<4;j++)
{
if(a[i]>首袭a[j])
temp=a[i];
a[i]=a[j];
a[j]=temp;
}
cout<<"the maximum number which build by the "<<num<<" is:"<<endl;
for(i=0;i<4;i++)
cout<<a[3-i];
cout<<endl;
cout<<"the minimum number which build by the "<<num<<" is:"<<endl;
for(i=0;i<4;i++)
cout<<a[i];
cout<<endl;

}