If input numbers are
82
2
% 3
+ 100
First number is our starting value and 2st number is how many lines do we have. Why is my char not reading the '+' and ading 100 to 82%3 => 1+100=101? And the output is just 82%3=1.
#include
#include
int v[10000];
int main()
{
FILE *fin, *fout;
int a, n, i, j, l, t, ts, cnt;
char ch;
fin = fopen("anaf.in", "r");
fout = fopen("anaf.out", "w");
ch = fgetc(fin);
i=0;
while(ch!='\\')
{
v[i]=ch-'0';
i++;
ch = fgetc(fin);
}
for(j=0; j i)
i=l;
}
else if(ch=='*')
{
t=l=0;
while(l 0)
{
t=t+a*v[l];
v[l]=t%10;
t=t/10;
l++;
}
if(l>i)
i=l;
}
else if(ch=='/')
{
t=0;
for(l=i-1; l>=0; l--)
{
t=t*10+v[l];
v[l]=t/a;
t=t%a;
}
while(i!=0 && v[i-1]==0)
i--;
}
else if(ch=='%')
{
t=0;
for(l=i-1; l>=0; l--)
{
t=t*10+v[l];
t=t%a;
}
if(t!=0)
{
ts=t;
cnt=0;
while(ts!=0)
{
cnt++;
ts=ts/10;
}
for(l=0; l =0; j--)
{
fprintf(fout, "%d", v[j]);
}
//fprintf(fout, "%d", t);
fclose(fout);
fclose(fin);
return 0;
}