2. 编写main函数,输入一个正整数,倒序输出其中的每一位数字,要求每位数字占5位宽 对齐。 编程。输入一个正整数,要求1.求出它是几位数 2.分别输出每...

\u7f16\u5199\u4e00\u4e2a\u7a0b\u5e8f\uff0c\u8f93\u5165\u4efb\u610f\u4e00\u4e2a\u6b63\u6574\u6570\uff0c\u5012\u5e8f\u8f93\u51fa\u4ed6\u7684\u6bcf\u4e00\u4f4d\u6570\u5b57\u662f\u591a\u5c11\uff0c\u8fd8\u6709\u8f93\u51fa\u4ed6\u6709\u51e0\u4f4d\u6570

#include
int main()
{int n,x;
scanf("%d",&x);
for(n=0;x;x/=10,n++)
printf("%d ",x%10);
printf("\n\u5b83\u662f%d\u4f4d\u6570\n",n);
return 0;
}

\u7528C\u8bed\u8a00\uff1f

#include

void main()
{
int i = 0, x, y[20];
printf("\u8f93\u5165\u6570\u5b57\uff1an = "); scanf("%d", &x);
while (x) {
y[i] = x % 10;
x /= 10;
i++;
}
printf("\n\u8fd9\u4e2a\u6570\u5b57\u5171\u6709 %d \u4f4d\u6570\u3002\n", i);
for (x = i; x > 0; x--) printf("%d, ", y[x - 1]); printf("\n");
for (x = 0; x < i; x++) printf("%d, ", y[x]); printf("\n");
}

你就在线等吧。5分钟后给你结果。。

#include <stdio.h>
#include <stdlib.h>
void main()
{
int i,num,nsize;
char *cnum=(char*)malloc(255);
scanf("%d",&num);
itoa(num,cnum,10);//将整数转成字符串
nsize=strlen(cnum);//取得大小
for (i=nsize-1;i>=0;i--) //逆序输出
{
printf("%4c",*(cnum+i));//这个是....1....6....8....2
printf("%-4c",*(cnum+i));//屏蔽上面第一条用下面的效果就是你想要的。
}
getch();

}

扩展阅读:编写函数main求3 6 9 ... 主函数不一定用main表示 ... int main int argc ... main已经被定义了怎么解决 ... main函数的位置怎么放 ... c语言中main前面要加int吗 ... java main函数怎么写 ... main函数可以调用main函数 ... 编写一个fac函数求n用main ...

本站交流只代表网友个人观点,与本站立场无关
欢迎反馈与建议,请联系电邮
2024© 车视网