|

楼主 |
发表于 2023-3-11 00:31:33
|
显示全部楼层
#include<conio.h>
#include<stdio.h>
#include<stdlib.h>
unsigned fun(unsigned w)
{
int t=1,n=1,z=1;
for(t=10;;t=t*10)
{
if(w/t>=0)
n++; //n是w的位数
else
break;
}
for(t=1;t<n;t++)
z=z*10; //z是后面0的个数
return w%z;
}
void main()
{
FILE *wf;
unsigned x;
system("CLS");
printf("Enter a unsigned integer number: ");
scanf ("%u",&x);
printf("The original data is:%u\n",x);
if(x<10)
printf("Data error! ");
else
printf ("The result :%u\n", fun(x));
/******************************/
wf=fopen("out.dat","w");
fprintf(wf,"%u",fun(5923));
fclose(wf);
/*****************************/
}
我的代码
|
|