PTA作业 输出整数各位数字


 

 

 

#include<stdio.h>
#include<math.h>
int main()
{
    int num,i;//先要知道位数
    int t=0;
    long int n,f;
    scanf("%ld",&n);
    f=n;
    if(n==0)
    {
        printf("0 ");//,尽管是0,也不要忘记数字后面的空格
    }else{
        do
        {
            n=n/10;
            t++;
        }while(n>0);
        while(t>0)
        {
            i=pow(10,t-1);
            printf("%d ",f/i);
            t--;
            f=f%i;
        }
    }
    return 0;
}

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM