Home > Back-end >  C language subject
C language subject

Time:02-09

School oj exponent de1000 2 single digits addition program fills up the topic o can't think out your great god see
# include & lt; Stdio. H>
# define X 1000
# define Y 400
Int Fun () {
Int a [Y]={2}, b [Y];
Int sum=0;
Int I, j, m, n;
for (i=1; iFor (j=0; JB [j]=[j];
For (n=0; nIf (n==0)
A [n]=2 * b [n] % 10;
The else
___________________________________.
}
For (m=0; mThe sum +=a, [m].
return sum;
}
Int main (void) {
Printf (" % d \ n ", Fun ());
return 0;
}

CodePudding user response:

Clear request, don't let people guess,

CodePudding user response:

Requirements:
2 ^ 15=32768, its all for the sum of 3 + 2 + 7 + 6 + 8=26,

The sum of 2 ^ 1000 digits, including ^ said the power, such as: 2 ^ 5 of 5 said 2 square,

Calculate and output the following program, please complete the missing statement, request contestants in understanding on the basis of the given code to fill in the missing parts, makes the program logic is correct, complete, fill in the code is not more than one statement (i.e., not a semicolon),

CodePudding user response:

If you can explain it by the way, this code without a clear this want why

CodePudding user response:

A [n]=([n] + 2 * 2 * b b/10) [n - 1] % 10

CodePudding user response:

Is, the value of the calculation of 2 1000 power, because it is too big, so you need to use an array element represents its digits, calculation of reference written calculation process of vertical,

CodePudding user response:

Hello can explain the train of thought is how to want to come out to write it

CodePudding user response:

Large number of ultra-high precision calculation basic were written so, online search a lot of, it is hard to simulate the vertical calculation, not only by 2, more important is four and a variety of other operations, of course, this code is not fine, there are some useless in there,

CodePudding user response:

According to the decimal from low to high place a calculate, considering the low carry to go into, if it is as you say, fill in the blanks of the words,

CodePudding user response:

Brother or can detailed comments first cycle from start to finish, please put me as a novice to explain this is really don't understand

CodePudding user response:

 
# include & lt; Stdio. H>
# define X 1000
# define Y 400
Int Fun () {
Int a [Y]={2}, b [Y];//had a 2
Int sum=0;
Int I, j, m, n;
For (I=1; I & lt; X; + + I) {//the loop 999 times, each time by 2
For (j=0; J & lt; Y; + + j)//the last result stored as the next operand
B [j]=[j];
For (n=0; N & lt; Y; + + n)//this is a=b * 2
If (n==0)
A [n]=2 * b [n] % 10;//least significant bits need not consider carry, because no one to give it into the
The else
A [n]=([n] + 2 * 2 * b b/10) [n - 1] % 10;//a is a carry to consider the other, a [1] is 10, a [2] is one hundred bits, and so forth
}
For (m=0; M & lt; Y; M++)//accumulation as required digital
The sum +=a, [m].
return sum;
}
Int main (void) {
Printf (" % d \ n ", Fun ());
return 0;
}

O
1366
  • Related