C++实现5位整数分解

C++实现5位整数分解

要求输入一个5位整数,分解出它的每位数字,每个数字间隔3个空格进行打印。

void resolve(int number){
	int n1,n2,n3,n4,n5;
	n5 = number/10000;
	n4 = number%10000/1000;
	n3 = number%10000%1000/100;
	n2 = number%10000%1000%100/10;
	n1 = number%10000%1000%100%10;
	cout<<n5<<"   "<<n4<<"   "<<n3<<"   "<<n2<<"   "<<n1<<endl;
}

int main(){
	int number;
	cout<<"请输入一个五位整数"<<endl;
	cin>>number;
	resolve(number);
	return 0;
}
上一篇:L1-019 谁先倒


下一篇:C语言电话线个数