Skip to content

Commit

Permalink
Update ex5_6.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
Mooophy committed Jun 22, 2015
1 parent 0655abe commit f210f14
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions ch05/ex5_6.cpp
Original file line number Diff line number Diff line change
@@ -1,22 +1,19 @@
#include <iostream>
#include <vector>
#include <string>

using std::vector; using std::string; using std::cout; using std::endl; using std::cin;

int main()
{
vector<string> scores = {"F", "D", "C", "B", "A", "A++"};
int grade{0};
vector<string> scores = { "F", "D", "C", "B", "A", "A++" };

int grade = 0;
while (cin >> grade)
{
string lettergrade = grade < 60 ? scores[0] : scores[(grade-50)/10];
lettergrade += (grade == 100 || grade < 60) ? "" :
(grade % 10 > 7) ? "+" :
(grade % 10 < 3) ? "-" : "";
string lettergrade = grade < 60 ? scores[0] : scores[(grade - 50) / 10];
lettergrade += (grade == 100 || grade < 60) ? "" : (grade % 10 > 7) ? "+" : (grade % 10 < 3) ? "-" : "";
cout << lettergrade << endl;
}

return 0;
}

0 comments on commit f210f14

Please sign in to comment.