Home > Back-end >  C a nested loop
C a nested loop

Time:10-13

Subject, the sum of factorial of 1 to 10, int t on the first, in the for after the second cycle, not to the first cycle, t become 1 again, so don't carlt factorial effect?

CodePudding user response:

You didn't see the following s put t of each time, after the t value is 1

CodePudding user response:

Every time t into 1 is to calculate the new factorial, take is depend on the number of times I change

CodePudding user response:

Can explain two loops

CodePudding user response:

Each loop, t have to start from 1, or idea is not right!

T is also not have to start from 1, only the code you want to change a kind of writing can

T=1; S=0;
For (I=1; I<=10; + + I) {
T *=I
S +=t;
}
This is possible, the inner loop is not
all over
It didn't, the book is to make people more easily understand, t is the I factorial
  • Related