Help translate C ++ code

var d1, d2, d3, k, n: integer; begin writeln('Введите число n, с которым будем сравнивать сумму цифр числа'); readln(n); k := 0; {d1 – левая, d2 – средняя, d3 – правая цифры числа} for d1 := 1 to 9 do for d2 := 0 to 9 do for d3 := 0 to 9 do if (d1 + d2 + d3 = n) then begin k := k + 1; write(d1, d2, d3, ' '); end; writeln('Количество искомых чисел равно –', k); end. 

Closed due to the fact that off-topic participants D-side , aleksandr barakin , Vladimir Martyanov , Qwertiy , Grundy 9 Apr '16 at 11:02 .

It seems that this question does not correspond to the subject of the site. Those who voted to close it indicated the following reason:

  • “Questions asking for help with debugging (“ why does this code not work? ”) Should include the desired behavior, a specific problem or error, and a minimum code for playing it right in the question . Questions without an explicit description of the problem are useless for other visitors. See How to create minimal, self-sufficient and reproducible example . " - D-side, Grundy
If the question can be reformulated according to the rules set out in the certificate , edit it .

  • @amora, To format a code, select it with the mouse and click on the {} button of the editor. - Praddos
  • Thanks for the advice) - amora
  • four
    I vote for the closure of this question, since the answer to it can hardly be useful to anyone other than the author of the question. - aleksandr barakin

1 answer 1

 #include <stdio.h> int main(int argc, char* argv[]) { int d1, d2, d3, k, n; printf("Введите число n, с которым будем сравнивать сумму цифр числа\n"); scanf("%d", &n); k = 0; for (d1 = 1; d1 <= 9; ++d1) ... ... if (d1 + d2 + d3 == n) { k += 1; printf("%d%d%d ", d1, d2, d3) } ... } 

What to insert instead of the last three, I think, will understand.