Home > Back-end >  Vertical calculator
Vertical calculator

Time:09-20

Using c language to complete, I will only a c + +

CodePudding user response:

Basic will be C to C + +, C is a subset of the C + +

CodePudding user response:

reference 1/f, Simple, Soft reply:
basic will C + +, C is a subset of the C + + o
not formatted string, there are some built-in function, feel good difficult

CodePudding user response:

Written in c + +, you help you "translated into" c

CodePudding user response:

Can use the scanf to accept input, vertical's hard indeed, such as 15 * 13, what should the final output?

CodePudding user response:

reference CHXCHXKKK reply: 3/f
you written in c + +, to help you "translated into" c
feel the output of the c + + write not to come out this complex

CodePudding user response:

Vertical that paragraph, I use C wrote a part of the remaining basic can get everything right, the C + + into C

 
Int count_place (int x)//calculate the number of digits
{
Int TMP=x;
int i=0;
While (TMP!=0 & amp; & )
{
TMP TMP/=10;
i++;
}
return i;
}

Void add_vertical (int a, int b)//addition upright
{
int i;
Int place_one=count_place (a);
Int place_two=count_place (b);
Int sum;
Sum=a + b;
Int place_three=count_place (sum);
If (place_one==place_two)
{
Printf (" \ n \ t % d ", a);
Printf (" \ \ n "t % d, b);
}
If (place_one & gt; Place_two)
{
Int the diff=place_one - place_two;
Printf (" \ n \ t % d ", a);
Printf (" + \ t ");
for(i=0; i{
Printf (" ");
}
Printf (" % d \ n ", b);
}
Printf (" -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- ");
//the same method, according to the difference and output the sum of figures is the correct upright
}

CodePudding user response:

string reference 7 floor of ground response:
vertical that a part I have written in C, the remaining basic can get everything right, the C + + into C

 
Int count_place (int x)//calculate the number of digits
{
Int TMP=x;
int i=0;
While (TMP!=0 & amp; & )
{
TMP TMP/=10;
i++;
}
return i;
}

Void add_vertical (int a, int b)//addition upright
{
int i;
Int place_one=count_place (a);
Int place_two=count_place (b);
Int sum;
Sum=a + b;
Int place_three=count_place (sum);
If (place_one==place_two)
{
Printf (" \ n \ t % d ", a);
Printf (" \ \ n "t % d, b);
}
If (place_one & gt; Place_two)
{
Int the diff=place_one - place_two;
Printf (" \ n \ t % d ", a);
Printf (" + \ t ");
for(i=0; i{
Printf (" ");
}
Printf (" % d \ n ", b);
}
Printf (" -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- ");
//the same method, according to the difference and output the sum of figures is the correct upright
}
the fifth row a slip of the pen

CodePudding user response:

Void the add (int a, int b)
{
Printf (" % d 10 9 d \ n \ n + % -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - \ n \ n \ n % 10 d ", a, b, a + b);
}
Void sub (int a, int b)
{
Printf (" % d 10 9 d \ n \ n - % -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - \ n \ n \ n % 10 d ", a, b, a - b).
}
Void the mul (int a, int b)
{
Int res=a * b;
Printf (" % d 10 9 d \ n \ n * % -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - \ n ", a, b);
Int count=1;
For (; B!=0;)
{
int c;
C=b % 10;
B=b/10;
Int I=a * c, j=0;
For (; The I!=0; J++)
{
I=I/10;
}
I=9 - I;
I=I - count;
For (; The I!=0; I -)
{
Printf (" ");
}
Printf (" % d \ n \ n ", a * c);
count++;
}
If (count!
=2){
Printf (" -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - 10 d \ n \ n \ n % ", res);
}
The else
printf("\n");
}
I wrote this myself, but I still have a little problem

CodePudding user response:

refer to the eighth floor response: string of implement
Quote: refer to 7th floor response: string of implement

Vertical that paragraph, I use C wrote a part of the remaining basic can get everything right, the C + + into C

 
Int count_place (int x)//calculate the number of digits
{
Int TMP=x;
int i=0;
While (TMP!=0 & amp; & )
{
TMP TMP/=10;
i++;
}
return i;
}

Void add_vertical (int a, int b)//addition upright
{
int i;
Int place_one=count_place (a);
Int place_two=count_place (b);
Int sum;
Sum=a + b;
Int place_three=count_place (sum);
If (place_one==place_two)
{
Printf (" \ n \ t % d ", a);
Printf (" \ \ n "t % d, b);
}
If (place_one & gt; Place_two)
{
Int the diff=place_one - place_two;
Printf (" \ n \ t % d ", a);
Printf (" + \ t ");
for(i=0; i{
Printf (" ");
}
Printf (" % d \ n ", b);
}
Printf (" -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- ");
//the same method, according to the difference and output the sum of figures is the correct upright
}
the fifth row a slip of the pen


nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related