Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- using namespace std;
- int main() {
- int days;
- cin >> days;
- cin.ignore();
- string command;
- double dayCash = 0;
- for (int i = 0; i < days; i++) {
- int dayProducts = 0;
- dayCash += 60;
- while (true) {
- getline(cin, command);
- if (command == "Day over") {
- printf("Money left from today: %.2f.", dayCash);
- break;
- }
- int productPrice = stoi(command);
- if (productPrice <= dayCash) {
- dayCash -= productPrice;
- dayProducts++;
- }
- if (dayCash == 0) {
- cout << "Daily limit exceeded!";
- break;
- }
- }
- cout << " You've bought " << dayProducts << " products.\n";
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement