Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int l[5];
- bool s1, s2, s3, s4, s5;
- void Pisz()
- {
- for (int i = 0; i < 5; i++)
- {
- cout << "l" << i+1 << " = "<<l[i]<<" ";
- }
- cout <<endl<< "s1 = " << s1 << " s2 = " << s2 << " s3 = " << s3 << " s4 = " << s4 << " s5 = " << s5 << endl;
- }
- void Ustaw()
- {
- if (l[0] > 0)
- s1 = true;
- else
- {
- s1 = false;
- }
- if (l[1] > 0)
- s2 = true;
- else
- {
- s2 = false;
- }
- if (l[2] > 0)
- s3 = true;
- else
- {
- s3 = false;
- }
- if (l[3] > 0)
- s4 = true;
- else
- {
- s4 = false;
- }
- if (l[4] > 0)
- s5 = true;
- else
- {
- s5 = false;
- }
- /*
- if (l[0] > 0)
- IOWR(LEDS_BASE, 0 , LEDS1 | IORD(LEDS_BASE,0))
- else
- {
- s1 = false;
- }
- if (l[1] > 0)
- IOWR(LEDS_BASE, 0 , LEDS2)
- else
- {
- s2 = false;
- }
- if (l[2] > 0)
- IOWR(LEDS_BASE, 0 , LEDS3)
- else
- {
- s3 = false;
- }
- if (l[3] > 0)
- IOWR(LEDS_BASE, 0 , LEDS4)
- else
- {
- s4 = false;
- }
- if (l[4] > 0)
- IOWR(LEDS_BASE, 0 , LEDS5)
- else
- {
- s5 = false;
- }
- */
- }
- int kier, s;
- int main()
- {
- kier = 1;
- s = 0;
- for (int i = 0; i < 5; i++)
- {
- l[i] = 1;
- }
- while (1)
- {
- Ustaw();
- Pisz();
- cout << endl << "podaj s ";
- cin >> s >> kier;
- /*
- kier = IORD(SW_SLIDERS_BASE, 0) & SW9;
- s = IORD(SW_SLIDERS_BASE, 0);
- if (s & SW1)
- {
- if (kier)
- {
- if (l[2] > 0)
- {
- l[0]++;
- l[2]--;
- }
- else
- cout << "Brak w pokoju 3\n"; // dioda bledu
- }
- else
- {
- if (l[0] > 0)
- {
- l[0]--;
- l[2]++;
- }
- else
- cout << "Brak w pokoju 1\n"; // dioda bledu
- }
- }
- else if (s & SW2)
- {
- if (kier)
- {
- if (l[0] > 0)
- {
- l[1]++;
- l[0]--;
- }
- else
- cout << "Brak w pokoju 1\n"; // dioda bledu
- }
- else
- {
- if (l[1] > 0)
- {
- l[1]--;
- l[0]++;
- }
- else
- cout << "Brak w pokoju 2\n"; // dioda bledu
- }
- }
- else if (s & SW3)
- {
- if (kier)
- {
- if (l[1] > 0)
- {
- l[4]++;
- l[1]--;
- }
- else
- cout << "Brak w pokoju 2\n"; // dioda bledu
- }
- else
- {
- if (l[4] > 0)
- {
- l[4]--;
- l[1]++;
- }
- else
- cout << "Brak w pokoju 5\n"; // dioda bledu
- }
- }
- else if (s & SW4)
- {
- if (kier)
- {
- if (l[4] > 0)
- {
- l[4]--;
- }
- else
- cout << "Brak w pokoju 5\n"; // dioda bledu
- }
- else
- {
- l[4]++;
- }
- }
- else if (s & SW5)
- {
- if (kier)
- {
- if (l[2] > 0)
- {
- l[3]++;
- l[2]--;
- }
- else
- cout << "Brak w pokoju 2\n"; // dioda bledu
- }
- else
- {
- if (l[3] > 0)
- {
- l[3]--;
- l[2]++;
- }
- else
- cout << "Brak w pokoju 5\n"; // dioda bledu
- }
- }
- */
- switch (s)
- {
- case 1:
- if (kier)
- {
- if (l[2] > 0)
- {
- l[0]++;
- l[2]--;
- }
- else
- cout << "Brak w pokoju 3\n";
- }
- else
- {
- if (l[0] > 0)
- {
- l[0]--;
- l[2]++;
- }
- else
- cout << "Brak w pokoju 1\n";
- }
- break;
- case 2:
- if (kier)
- {
- if (l[0] > 0)
- {
- l[1]++;
- l[0]--;
- }
- else
- cout << "Brak w pokoju 1\n";
- }
- else
- {
- if (l[1] > 0)
- {
- l[1]--;
- l[0]++;
- }
- else
- cout << "Brak w pokoju 2\n";
- }
- break;
- case 3:
- if (kier)
- {
- if (l[1] > 0)
- {
- l[4]++;
- l[1]--;
- }
- else
- cout << "Brak w pokoju 2\n";
- }
- else
- {
- if (l[4] > 0)
- {
- l[4]--;
- l[1]++;
- }
- else
- cout << "Brak w pokoju 5\n";
- }
- break;
- case 4:
- if (kier)
- {
- if (l[4] > 0)
- {
- l[4]--;
- }
- else
- cout << "Brak w pokoju 5\n";
- }
- else
- {
- l[4]++;
- }
- break;
- case 5:
- if (kier)
- {
- if (l[2] > 0)
- {
- l[3]++;
- l[2]--;
- }
- else
- cout << "Brak w pokoju 2\n";
- }
- else
- {
- if (l[3] > 0)
- {
- l[3]--;
- l[2]++;
- }
- else
- cout << "Brak w pokoju 5\n";
- }
- break;
- }
- }
- getchar();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement