fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. struct STUDENT_SCORE
  5. {
  6. char name[16];
  7. char id[16];
  8. int eng;
  9. };
  10.  
  11. #include <vector>
  12.  
  13. int main()
  14. {
  15. vector< STUDENT_SCORE > scores;
  16. char inputs[ 256 ];
  17. int orders[101] = { 0 };
  18.  
  19. while( cin.getline( inputs, sizeof inputs ) )
  20. {
  21. STUDENT_SCORE score;
  22. sscanf( inputs, "%s%s%u", score.name, score.id, &score.eng );
  23. scores.emplace_back( score );
  24. orders[ score.eng ]++;
  25. }
  26.  
  27. int accumulation = scores.size();
  28. for( auto& order : orders )
  29. order = ( accumulation -= order ) + 1;
  30.  
  31. for( const auto& score : scores )
  32. cout << score.name << " " << score.id << " " << score.eng << " "
  33. << orders[ score.eng ] << endl;
  34.  
  35. return 0;
  36. }
  37.  
Success #stdin #stdout 0s 3464KB
stdin
가가 1111 80
나나 2222 80
다다 3333 70
라라 4444 70
stdout
가가 1111 80 1
나나 2222 80 1
다다 3333 70 3
라라 4444 70 3