fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. //I'm going to make an alias to cin, just so we can pretend
  6. //the code later is reading from a file
  7. istream& fin = cin; //just pretend I opened a file here
  8.  
  9. int num_lines; //read the first line of the file
  10. fin >> num_lines; //to see how many lines need to be read
  11.  
  12. double A=0, B=0, C=0, D=0, E=0; //initalize all the totals to zero
  13.  
  14. for(int i=0; i<num_lines; ++i) {
  15. char team;
  16. double score;
  17. fin >> team >> score; //read team and score from each line
  18.  
  19. //use a switch statement on team to figure out which variable
  20. //your program should add score to
  21. }
  22.  
  23. //do whatever else you need to do with the tallied scores
  24.  
  25. return 0;
  26. }
Success #stdin #stdout 0s 3456KB
stdin
14 
C 12.50 
B 31.75 
A 12.00 
C 43.75 
E 28.50 
D 48.25 
E 33.50 
A 29.50 
B 51.00 
D 46.75 
C 19.50 
E 54.75 
B 45.50 
D 15.25 
stdout
Standard output is empty