can't solve this."n" numbers are given.Calculate the sum of the digits for every number & output the lowest number of these sums | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

can't solve this."n" numbers are given.Calculate the sum of the digits for every number & output the lowest number of these sums

I did a program, buy it isn't correct. I don't understand it that much so i can solve it.Please help. C++ https://code.sololearn.com/c7Mow0AqeHfY/?ref=app

26th Oct 2019, 9:30 AM
George Listru
George Listru - avatar
8 Answers
+ 3
Do you want to keep the sums of the digits? I saw your question said about sort the sums in descending order. I see you already understand how to sum the digits in each number. So tell me which part of this that you need help with? maybe I can try something to help you out.
26th Oct 2019, 3:13 PM
Ipang
+ 3
Okay give me a few minutes, I'll see what I can do ...
26th Oct 2019, 3:25 PM
Ipang
+ 2
Can you give me an example about what input and what output is supposed to be generated? I don't think I'm understanding your problem description clearly.
26th Oct 2019, 2:07 PM
Ipang
+ 1
Input 2-i want to use 2 numbrrs 335 455-these are the numbers ---- 3+3+5=11 4+5+5=14 ---- Output 335 is the lowest number
26th Oct 2019, 2:54 PM
George Listru
George Listru - avatar
+ 1
I need to display the lowest sum in the form from the input, that's 335 The program has to calculate 3+3+5 , but display 335
26th Oct 2019, 3:23 PM
George Listru
George Listru - avatar
+ 1
Well, finally done, take a look at this one, I use 2 arrays, one for the numbers, and another for sum of digits of each number. A sorting is also performed for the <sums> array. Hope this gives you an idea, and hopefully I got your explanation right. https://code.sololearn.com/cUcnAEhrSSm1/?ref=app
26th Oct 2019, 4:41 PM
Ipang
+ 1
Thanks man.I apreciate that.I understand now
26th Oct 2019, 4:54 PM
George Listru
George Listru - avatar
+ 1
Okay no problem : ) Don't hesitate to ask if there is any doubt, it's fine 👍
26th Oct 2019, 5:01 PM
Ipang