subject
Computers and Technology, 01.09.2019 14:30 anyar

Ihave to writea piece of code to calculate the factorial of somewhat large numbers so the long long type won't suffize, so using vector, i stumbled upon some issues during run time:
'#include
#include
using namespace std;
vector factorial(short n)
{
vector v, z;
do
{
short m = n%10;
v. push_back(m);
}while(n/=10);
short temp = 0;
int x;
//short m = 0;
while(n-1)
{
for(auto & w : v)
{
x = w*(n-1) + temp;
temp = x/10;
z. push_back(x%10);
}
}
return z;
}
int main()
{
short t;
cin > > t;
vector v;
short temp;
while(
{
cin > > temp;
v. push_back(temp);
}
vector tmp;
for(auto & w : v)
{
tmp = factorial(w);
for(auto i=tmp. end(); i! =tmp. begin();
cout < < *i;
cout < < endl;
}
return 0;
}
'

ansver
Answers: 1

Other questions on the subject: Computers and Technology

image
Computers and Technology, 23.06.2019 03:00, jarteria0
State 7 common key's for every keyboard
Answers: 1
image
Computers and Technology, 23.06.2019 15:00, med69
Barbara is interested in pursuing a career in the science and math pathway. which qualifications will her reach that goal? a. an advanced knowledge of physics and math b. an advanced knowledge of engineering and math c. an advanced knowledge of physics and robotics an d. advanced knowledge of machinery and math
Answers: 2
image
Computers and Technology, 23.06.2019 19:00, jaymc1932
Whose task it is to ensure that the product flows logically from one step to another?
Answers: 3
image
Computers and Technology, 23.06.2019 21:20, nathanfletcher
In microsoft word, when you highlight existing text you want to replace, you're in              a.  advanced mode.    b.  automatic mode.    c.  basic mode.    d.  typeover mode
Answers: 1
You know the right answer?
Ihave to writea piece of code to calculate the factorial of somewhat large numbers so the long long...

Questions in other subjects: