问题描述
编写一个程序,输入一个1000 以内的正整数,然后把这个整数的每一位数字都分离出来,并逐一地显示。
输入格式:输入只有一行,即一个1000以内的正整数。
输出格式:输出只有一行,即该整数的每一位数字,之间用空格隔开。
输入输出样例
输入格式:输入只有一行,即一个1000以内的正整数。
输出格式:输出只有一行,即该整数的每一位数字,之间用空格隔开。
输入输出样例
样例输入
769
样例输出
7 6 9
作者笔记:本题要注意临界情况。
1 #include<stdio.h> 2 int main(){ 3 int a,b,c,n; 4 long i; 5 scanf("%d",&n); 6 if(n<=9){ 7 printf("%d",n); 8 } 9 else if(n>9 && n<=99){ 10 b = n / 10 % 10; 11 c = n / 1 % 10; 12 printf("%d %d",b,c); 13 } 14 else if(n>99){ 15 a = n / 100 % 10; 16 b = n / 10 % 10; 17 c = n / 1 % 10; 18 printf("%d %d %d",a,b,c); 19 } 20 }