Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- template <typename T> T getVar(const char* str) { T result; std::cout << str << std::endl; std::cin >> result; return result; }
- struct znakZodiaku { const char* m_str; int m_miesiac, m_dzien; };
- static znakZodiaku g_znaki[] = { { "koziorozec", 1, 1 }, { "wodnik", 1, 20 }, { "ryby", 2, 19 }, { "baran", 3, 21 }, { "byk", 4, 20 }, { "bliznieta", 5, 23 }, { "rak", 6, 22 }, { "lew", 7, 23 }, { "panna", 8, 24 }, { "waga", 9, 23 }, { "skorpion", 10, 23 }, { "strzelec", 11, 22 }, { "koziorozec", 12, 22 }, { "###", 13, 1 } };
- const char* ustalZnak(int dzien, int miesiac) {
- const char* result = "nie znaleziono!";
- for(int i = 0; i < ((sizeof(g_znaki)/sizeof(znakZodiaku))-1); ++i)
- if((miesiac == g_znaki[i].m_miesiac && dzien >= g_znaki[i].m_dzien) || (miesiac > g_znaki[i].m_miesiac)) result = g_znaki[i].m_str;
- return result;
- }
- int main() {
- std::cout << "program do sprawdzania znaku zodiaku" << std::endl;
- std::cout << "znak zodiaku: " << ustalZnak(getVar<int>("podaj dzien miesiaca twoich urodzin: "), getVar<int>("podaj miesiac swoich urodzin: "));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement