fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. float sco1(char n) {
  5. if (n == 'A')
  6. return 4;
  7. if (n == 'B')
  8. return 3;
  9. if (n == 'C')
  10. return 2;
  11. if (n == 'D')
  12. return 1;
  13.  
  14. }
  15.  
  16. float sco2(char n) {
  17. if (n == '+')
  18. return 0.3;
  19. else if (n == '0')
  20. return 0.0;
  21. else
  22. return -0.3;
  23. }
  24.  
  25. int main() {
  26. char score[2];
  27.  
  28. cin >> score[0];
  29.  
  30. if (score[0] == 'F')
  31. cout << "0";
  32. cin >> score[1];
  33.  
  34.  
  35.  
  36.  
  37. float result = sco1(score[0]) + sco2(score[1]);
  38.  
  39. cout << result << endl;
  40. return 0;
  41. }
Success #stdin #stdout 0.01s 5332KB
stdin
A0
stdout
4