When I started to make this code I encountered problem with string and switch statement that's why I am not sure that I bypassed this problem correctly. And the main problem is that program print answers only for chart but not for string determinations. Maybe that's because use wrong ''If". Here is my code :
#include <iostream> #include <string> using std::cin; using std::cout; using std::string; using namespace std; constexpr long long string_hash(const char *s) { long long hash{}, c{}; for (auto p = s; *p; ++p, ++c) { hash += *p << c; } return hash; } constexpr long long operator"" _sh(const char *s, size_t) { return string_hash(s); } int main() { cout << "Ievadiet atzimi ar burtiem (A, B, C, D, F) ==> "; string atzime; char burts; double atzime_sk, pluss, minuss; cin >> atzime; burts = atzime[0]; switch(burts) { case 'A': atzime_sk = 4; cout << "Tava atzime ir ==> " << atzime_sk; break; case 'B': atzime_sk = 3; cout << "Tava atzime ir ==> " << atzime_sk; break; case 'C': atzime_sk = 2; cout << "Tava atzime ir ==> " << atzime_sk; break; case 'D': atzime_sk = 1; cout << "Tava atzime ir ==> " << atzime_sk; break; case 'F': atzime_sk = 0; cout << "Tava atzime ir ==> " << atzime_sk; break; default: break; } if (atzime[1] == '-' || '+') { switch (string_hash(atzime.c_str())) { case "+"_sh: pluss = atzime_sk + 0.3; cout << "Tava atzime ir ==> " << atzime_sk; break; case "-"_sh: minuss = atzime_sk - 0.3; cout << "Tava atzime ir ==> " << atzime_sk; break; default: break; } } }