Advertisement
Guest User

plecaki c++ KK 3Ti

a guest
Oct 17th, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.43 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstdio>
  3. #include <cmath>
  4. using namespace std;
  5.  
  6. int main ()
  7. {
  8.  
  9. int ilePlecakow;
  10. int dopelnienie;
  11.  
  12.  
  13. cout << "Ile chcesz plecakow?";
  14. cin >> ilePlecakow;
  15.  
  16. int pojemnosc[ilePlecakow];
  17.  
  18. for(int i=1; i<=ilePlecakow;i++)
  19. {
  20. cout << "Podaj pojemnosc plecaka nr " << i << endl;
  21. cin >> pojemnosc[i];
  22. }
  23.  
  24. int plecak[ilePlecakow];
  25.  
  26.  
  27.  
  28.  
  29.  
  30. for(int a=1; a<=ilePlecakow; a++)
  31. {
  32. plecak[a]=0;
  33. while(plecak[a]<pojemnosc[a])
  34. {
  35.  
  36. cout << "\n O ile chcesz dopelnic? plecak nr " << a << "?";
  37. cin >> dopelnienie;
  38. if(plecak[a]+dopelnienie<=pojemnosc[a])
  39. {
  40. plecak[a]+=dopelnienie;
  41. cout << "zapelnienie plecaka nr" << a << ": " << plecak[a];
  42. }
  43. else
  44. {
  45. cout << "Przepelniony plecak!";
  46. }
  47.  
  48. }
  49.  
  50.  
  51. }
  52.  
  53.  
  54.  
  55.  
  56.  
  57. for(int x=1; x<=ilePlecakow; x++)
  58. {
  59. cout << endl << "\nplecak nr:" << x << " zapolniony " << plecak[x] << " na " << pojemnosc[x];
  60. }
  61.  
  62. cin.ignore();
  63. getchar();
  64. return 0;
  65.  
  66.  
  67.  
  68. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement