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