Created
November 30, 2013 18:19
-
-
Save fcamel/7722525 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <set> | |
enum Type { | |
A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z | |
}; | |
bool isOkayBySwitch(Type type) { | |
switch (type) { | |
case A: | |
case C: | |
case D: | |
case E: | |
case G: | |
case I: | |
case K: | |
case L: | |
case Y: | |
return false; | |
default: | |
; | |
} | |
return true; | |
} | |
bool isOkayByIf(Type type) { | |
if (type == A | |
|| type == C | |
|| type == D | |
|| type == E | |
|| type == G | |
|| type == I | |
|| type == K | |
|| type == L | |
|| type == Y) { | |
return false; | |
} | |
return true; | |
} | |
bool isOkayByAlotOfIf(Type type) { | |
if (type == A) { | |
return false; | |
} else if (type == C) { | |
return false; | |
} else if (type == D) { | |
return false; | |
} else if (type == E) { | |
return false; | |
} else if (type == G) { | |
return false; | |
} else if (type == I) { | |
return false; | |
} else if (type == K) { | |
return false; | |
} else if (type == L) { | |
return false; | |
} else if (type == Y) { | |
return false; | |
} | |
return true; | |
} | |
struct Record | |
{ | |
Record() | |
{ | |
m_blacklist.insert(A); | |
m_blacklist.insert(C); | |
m_blacklist.insert(D); | |
m_blacklist.insert(E); | |
m_blacklist.insert(G); | |
m_blacklist.insert(I); | |
m_blacklist.insert(K); | |
m_blacklist.insert(L); | |
m_blacklist.insert(Y); | |
} | |
bool isOkayBySet(Type type) | |
{ | |
return m_blacklist.count(type) == 0; | |
} | |
std::set<Type> m_blacklist; | |
}; | |
Record s_record; | |
int main(void) { | |
int n; | |
std::cin >> n; | |
Type t = static_cast<Type>(n); | |
std::cout << isOkayBySwitch(t) << std::endl; | |
std::cout << isOkayByIf(t) << std::endl; | |
std::cout << isOkayByAlotOfIf(t) << std::endl; | |
std::cout << s_record.isOkayBySet(t) << std::endl; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment