need some insight

SO i have to add each person's final total of sum together and if it exceeds the winner then it should print out "it took number 1 - k" k being the last person it took to exceed the winners total. Im having issues on how to add the final sum together and its confusing me. Any insights would be appreciated.
This is what i have so far

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
int sumofFinal;
 int k;
	int sum = 0;
	
	for (int t = 0; t < 10; t++)
	{
		if (IDD == Programmer[t].ID)
		
			sum += Programmer[t].lineOfCode;
			

			if (Programmer[t].lineOfCode > sumofFinal)
			{
				k = IDD;
				cout << k;
			}
		}
Last edited on
So i have already found the winner and added the sum of each person. Now i have to add the sum of each person again and see how many people it took to exceed the sum of the winner. I hope this solve any confusion

 
.
Last edited on
Do you want a sample of the output? The winner is 9 btw so i would need to write a code that prints out "it took 1-7 to exceed the winner". Thats where im stuck on i have been thinking about it

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
Final Totals
Programmer  Lines of Code   
1      51       

2      105       

3      309       

4      101       

5      215       

6      0       

7      333      

8      462       

9      1077       

10      800       
tht sounds same too and im not sure how to write the code to do that
those are temp variables to read in and store the id , code and comment. Code is the sum. Just ignore the comment i just need to have it
Last edited on
ahh i managed to fix it. thank you so much
Topic archived. No new replies allowed.