#include "stdafx.h"
#include "string.h"
void mydiv(int a,int b,int c[10])
{
memset(c,0,10*sizeof(int));
int iters=0;
int mod=0;
c[0]=a/b;
mod=a%b;
while((iters<9) && (mod!=0))
{
iters++;
c[iters]=mod*10/b;
mod=mod*10%b;
}
}
int main(int argc, char* argv[])
{
int c[10];
mydiv(50,3,c);
for(int i=0;i<10;i++)
printf("%d-",c[i]);
printf("\n%f\n",50.0/3);
mydiv(50,2,c);
for(i=0;i<10;i++)
printf("%d-",c[i]);
printf("\n%f\n",50.0/2);
return 0;
}
/*
16-6-6-6-6-6-6-6-6-6-
16.666667
25-0-0-0-0-0-0-0-0-0-
25.000000
Press any key to continue
*/
mydiv(int a,int b,int c[10])
最新推荐文章于 2022-03-29 16:19:38 发布