Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int vwsselect(int xpos, int ypos, int ile, va_list vv) { // ujemne ile powoduje nieczyszczenie
- size_t szer;
- char key, poz;
- bool czysc=true;
- if (ile<0) {
- czysc=false;
- ile*=-1;
- }
- std::vector<const char*> v;
- for (poz=0; poz<ile; poz++) {
- v.push_back(va_arg(vv, const char*));
- szer=std::max(szer, strlen(v.back()));
- }
- for (poz=0; poz<ile; poz++) {
- cpos(xpos+poz, ypos);
- printf("%-*s", szer, v[poz]);
- }
- poz = 0;
- for (;;) {
- if (_kbhit()) {
- key = _getch();
- if (key == 'e') {
- break;
- }
- if (key == 'w' && poz > 0) poz--;
- if (key == 's' && poz < ile-1) poz++;
- if (poz > 0) {
- cpos(poz+xpos-1, ypos-1);
- printf(" ");
- }
- cpos(poz+xpos, ypos-1);
- printf(">");
- if (poz < ile-1) {
- cpos(poz+xpos+1, ypos-1);
- printf(" ");
- }
- }
- }
- if (czysc)
- clearwindow(xpos, ypos-1, szer+1, ile);
- return poz;
- }
- int wsselect(int xpos, int ypos, int ile, ...) { // ujemne ile powoduje nieczyszczenie
- va_list vv;
- va_start(vv, ile);
- int ret=vwsselect(xpos, ypos, ile, vv);
- va_end(vv);
- return ret;
- }
- void whoami() {
- cpos(5, 3);
- printf("Kim byl twoj ojciec?");
- ojciec=wsselect(5, 5, 9, "humanista", "geografem", "sportowcem", "informatykiem", "mikrobiologiem", "prawnikiem", "lekarzem", "zulem", "tirowcem");
- cpos(5, 3);
- printf("Kim byla twoja matka?");
- matka=wsselect(5, 5, 8, "humanistka", "modelka", "sportowcem", "informatykiem", "mikrobiologiem", "prawnikiem", "lekarzem", "bibliotekarka");
- }
Advertisement
Add Comment
Please, Sign In to add comment