码迷,mamicode.com
首页 > 其他好文 > 详细

求任意正整数的各位数字

时间:2019-12-08 15:59:14      阅读:78      评论:0      收藏:0      [点我收藏+]

标签:ret   bsp   nbsp   int   长度   style   pre   std   oid   

//求 任意正整数数字的各位数字
#include<stdio.h>
int a[100];// 数字长度大于100位时,修改即可
void get(int n){
    int i = 0;
    while(n != 0){
        int x = n%10;
        a[i] = x;
        i++;
        n /= 10;
    }
    for(int j = i-1; j >= 0 ;j--){
        printf("%d ",a[j]);
    }
}

int main(){
    int n;
    scanf("%d",&n);
    get(n);
    return 0;
}

 

求任意正整数的各位数字

标签:ret   bsp   nbsp   int   长度   style   pre   std   oid   

原文地址:https://www.cnblogs.com/expedition/p/12005776.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!