c++ - spoj http://www.spoj.com/problems/JULKA/ -


Explain below for the

  // loop which is actually being done in this loop / for (i = K-1, j = a = f = 0; i> = 0; i--) {b = (one * 10 + floating [i] - '0') / 2; // explain = (one * 10 + floating [i] - '0')% 2; // Explain if (B) F = 1; // clarification if (f) claudia [j ++] = b + 0 '; // clarification} if (! J) j ++; // Claudea [J] = 0; Explain for I (, i =, len1-1, j = len2-1, k = c = 0; i & gt; = 0; i -, j--, k ++) {a = total [i] - '0'; // explain b = j & gt; = 0? Diff [j] - '0': 0; // Explain that (a & lt; b + c) {temp [k] = (10 + abc) + '0'; // explain c = 1; // Definition} Else {temp [k] = abc + '0'; // clarification c = 0; // explain}} temp [k] = 0; // explain  

Explain what is happening in the loop from above to both that why we are divided by 2 and modulating by 2. The first loop expresses the decimal number as a string in the temporary [2]

2/2 is to literally divide one digit by 2, and 2% to apply the remaining digits to the next digit - which is why it is multiplied by 10.

The addition and subtraction of '0' is to convert a digit between one digit in the form of a letter and its ASCII representation is in the form of a character.


Comments

Popular posts from this blog

ios - How do I use CFArrayRef in Swift? -

eclipse plugin - Run java code error: Workspace is closed -

c - Error on building source code in VC 6 -