输入一个5位数的整数,将其分离成单独的数字,分离结果之间用3个空格分开

[复制链接]
查看11 | 回复1 | 2007-4-19 19:29:16 | 显示全部楼层 |阅读模式
最简单的办法://///////C++开始#includevoid main(){
int n;
cin>>n;
coutint main(){
int n;
scanf("%d", &n);
printf("%d ",n/10000);
printf("%d ",n%10000/1000);
printf("%d ",n%1000/100);
printf("%d ",n%100/10);
printf("%d",n%10);
return 1;}//////结束你要求三个空格,我用了四个空格,你不介意吧.
回复

使用道具 举报

千问 | 2007-4-19 19:29:16 | 显示全部楼层
// 楼上的是C版本// c++版本// 要java版本可以给我发邮件[email protected]#include using namespace std;int main(){int num;cout > num;for(int i = 10000; i int main( ){int n, t = 10000;scanf("%d", &n);while ( t ){
printf("%d ", n / t );
n %= t;
t /= 10;}return 0;}
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行