同学,我尽一点微薄之力啊!首先希望同学在将自己的代码给别人看并且希望别人给你改正时,需要在一些重要的代码段后面写上注释语句哦!因为这样可以让别人看每句代码时意思和思路一目了然!不然会很迷糊的哦!下面是我给你写的一些代码:
#include
#include
#include
int main ()
{
long int i,j,k,n,m,totle;
printf("Please Input The Big Number:"); /*提示需要输入的大数*/
scanf("%ld",&n); /*输入的大数*/
printf("The Big Number Is:%ld",n);/*显示大数*/
printf("\nInput The Totle Digits Of The Number:");/*提示输入的大数的位数*/
scanf("%ld",&totle);
m=totle;
for(k=1;k<=m;k++) /*循环输出将大数拆分后的每位数*/
{
i=n; /*对i初始化为大数数值*/
i=i/pow(10,totle-1); /*对i去整数,pow()是幂函数,pow(10,2)=10^2=100*/
j=i%10; /*对i进行求余运算,并赋值给j,这里j值就是将大数模拟拆分后输出的大数第一位数字值*/
printf("%ld ",j);
totle--;
}
printf("\n");
system("pause");
return 0;
}
如果仍然需要我帮你改正你自己写的代码程序,希望讲的详细一点哦!我会继续帮你的!
#include
#include
#include
void main()
{
int max;
int i=0;
int copymax;
printf("请输入一个大数\n");
scanf("%d",&max);
printf("这个大数为: %d\n",max);
copymax=max; //将max 拷贝给copymax 用copymax去确定 这个大数 是几位数
for(i=0;copymax!=0;i++)
{
copymax=copymax/10;
}
printf("这个大数为 %d 位数\n",i);
printf("孩子应该这样去读\n");
for(i;i!=0;i--)
{
int j;
j=max/(int)(pow(10,i-1)); //将大数的 最高为 存储到j中
max=max%(int)(pow(10,i-1)); //将大数最高位去掉
printf("%d\n",j); //将 j输出 j为 应该读取的 数
}
}
其实我觉得这个题目最好用对十求余,再除10,去精度,做个循环,跳出条件是最后除完为0
每次循环存入整形数组里,然后倒序输出数组内容即可
不知道你为什么要这么写,下边是我自己用比较简单的递归写的,可能格式和要求的不符:
#include
#include
int main ()
{int n;
void Convert(int n);
scanf("%d",&n);
Convert(n);
system("pause");
return 0;
}
void Convert(int n)
{
if(n==0)return;
Convert(n/10);
printf("%d ",n%10);
}
这道题估计是应该考的数据结构中的栈。
没考虑输入数的位数,就用的INT型;
vc6.0能通过
#include
int num[12];
int main()
{
int a;
int count=0;
int temp;
int i;
scanf("%d",&a);
while(a)
{
temp=a%10;
num[count]=temp;
count=count+1;
a=a/10;
}
for(i=count-1;i>=0;i--)
printf("%d ",num[i]);
printf("\n");
return 0;
}