很弱的c++程序问题

来源:百度知道 编辑:UC知道 时间:2024/06/06 10:04:10
输入一个不大于2^32的正整数,按顺序输出:
1,它的位数
2,分别打印出每一位数
3,逆序打印出个位数字

用最简单的方法……
拜托给出完整程序
另:不用用数组吧?

你参考一下
#include<stdio.h>
#include <conio.h>
void main(void)
{
char data[10];
char temp;
int i=0,n=0;

for(;;)
{
temp=getchar();
if(temp=='\n')
break;
data[n]=temp;
n++;
}

printf("wei shu shi %d\n",n);
for(i=0;i<n;i++)
printf("%c\n",data[i]);

printf("\n");

for(i=n-1;i>= 0;i--)
printf("%c\n",data[i]);