traditional long division c++

I need to write a program for traditional long division My program shows the correct answer of remainder and quotient but doesnot show the full division method like we do in copy..the tradional style..do u guys have any ideas????



#include<iostream>
#include<fstream>
#include<vector>
using namespace std;
struct cal
{
int num1,num2;
};
int funct(int);
vector<int>a;
void main(int argc,char*argv[1])
{
ifstream infile;
infile.open("add.txt");
int count;
infile>>count;
cal add;int m,p,n,d,i=1;
for(int j=1;j<=count;j++)
{

infile>>add.num1;
infile>>add.num2;
m=add.num1;
p=add.num1;
n=add.num1;
d=add.num2;
while(p>=10)
{
i=(i*10);
p=p/10;
}
for(int k=1;k<=count;k++)
{
n=funct(n);
}
for(unsigned int c=0; c<a.size();c++)
{
}

int b=0,h=a[0],cnt=a.size()-1;
bool f=false;
cout<<endl<<"number : "<<j<<endl;
cout<<"\n\nProblem Solution:\n\n";
cout<<" "<<"\t"<<m/d<<" R "<<m%d<<endl;
cout<<"\t------\n";
cout<<" "<<d<<" | "<<m;

while(a[b]!=a[cnt])
{
if(d>h)
{
b++;
h = 10*h+a[b];
}

else
{
if(f==true)
cout<<endl<<"\t"<<h;
cout<<endl<<" "<<"\t"<<(h/d)*d<<endl;
h = h%d;
f = true;
cout<<"\t----";
}
}

cout<<endl<<"\t"<<h<<endl;
}
system("PAUSE");
}

int funct(int v)
{
int count=0,p;
p = v;
int i=1;

while(p>=10)
{
i=(i*10);
p=p/10;
count++;
}
a.push_back(p);
return v-p*pow(10.000,count);
}
by the way..the input file is...

2
1572
9
543210
78
[code] "Your code goes here" [/code]
Your program is confusing. Use more meaningful names, and comment your code.
Topic archived. No new replies allowed.