Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- #define SIZE 5
- int tab[SIZE];
- int bat[SIZE];
- char x;
- int n, i;
- int w = 0;
- int main() {
- cout << "Wpisz instrukcje, ktora chcesz aktywowac: ";
- while (cin >> x) {
- if (x == 'A') {
- if (w < SIZE) {
- cin >> n;
- tab[w] = n;
- bat[w] = n;
- w++;
- }
- } else if (x == 'I') {
- cin >> n;
- cin >> i;
- tab[i] = n;
- } else if (x == 'P') {
- cin >> i;
- for (int j =0; j<SIZE; j+=i) {
- cout << bat[j] << " " <<endl;
- }
- } else if (x == 'M') {
- for (int z=0; z<SIZE-1; z++)
- for (int y=0; y<SIZE-1; y++)
- if (bat[y]>tab[y+1])
- swap(tab[y], tab[y+1]);
- cout << tab[0] << " " << tab[1] << endl;
- } else if (x == 'Q') {
- break;
- } else {
- cout << "Nie ma takiej instrukcji";
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement