Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstdio>
- #include <cmath>
- using namespace std;
- int main ()
- {
- int ilePlecakow;
- int dopelnienie;
- cout << "Ile chcesz plecakow?";
- cin >> ilePlecakow;
- int pojemnosc[ilePlecakow];
- for(int i=1; i<=ilePlecakow;i++)
- {
- cout << "Podaj pojemnosc plecaka nr " << i << endl;
- cin >> pojemnosc[i];
- }
- int plecak[ilePlecakow];
- for(int a=1; a<=ilePlecakow; a++)
- {
- plecak[a]=0;
- while(plecak[a]<pojemnosc[a])
- {
- cout << "\n O ile chcesz dopelnic? plecak nr " << a << "?";
- cin >> dopelnienie;
- if(plecak[a]+dopelnienie<=pojemnosc[a])
- {
- plecak[a]+=dopelnienie;
- cout << "zapelnienie plecaka nr" << a << ": " << plecak[a];
- }
- else
- {
- cout << "Przepelniony plecak!";
- }
- }
- }
- for(int x=1; x<=ilePlecakow; x++)
- {
- cout << endl << "\nplecak nr:" << x << " zapolniony " << plecak[x] << " na " << pojemnosc[x];
- }
- cin.ignore();
- getchar();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement