Talnex / Striving

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

数字分割

Talnex opened this issue · comments

using namespace std;

int main()
{
	int a,i;
	cin>>a;
	for(i = 5;i>0;i--){
		if(a/(int)pow(10.0,i-1)!=0) {
		    break;
		}
	}
	int* nums = new int[i];
    
	for(int j = i-1;j >= 0;j--){
		nums[j] = a/(int)pow(10.0,j);
		a = a%(int)pow(10.0,j);
	}
	cout<<i<<endl;
	for(int k=i-1;k>0;k--)
	cout<<nums[k]<<" ";
	cout<<nums[0]<<endl;
	for(int k=0;k<i;k++)
	cout<<nums[k];
	cout<<endl;
	return 0;
}