Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "stdafx.h"
- #include <iostream>
- using namespace std;
- int size_of_plot = 2;
- int rotten_counter = 0;
- int good_counter = 0;
- void age_kiwi_row(int row);
- bool check_row_ready_for_picking(int row);
- void pick_kiwis(int row);
- void show_plot();
- int kiwiplot[2][2] = { { 12, 11 },{ 1,0 } };
- int main()
- {
- for (int d = 0; d <= 7; d++)
- {
- if (d == 0)
- {
- for (int i = 0; i < size_of_plot; i++)
- {
- age_kiwi_row(i);
- }
- }
- for (int i = 0; i < size_of_plot; i++)
- {
- if (check_row_ready_for_picking(i))
- {
- pick_kiwis(i);
- }
- else
- {
- if (d != 0 && d != 7)
- {
- age_kiwi_row(i);
- }
- }
- }
- cout << "Plot after day: " << d << endl;
- show_plot();
- cout << endl;
- }
- cout << "Good yield: " << good_counter << endl;
- cout << "Rotten: " << rotten_counter << endl;
- system("pause");
- return(0);
- }
- void age_kiwi_row(int row)
- {
- for (int j = 0; j <= 1; j++)
- {
- kiwiplot[row][j]++;
- }
- return;
- }
- bool check_row_ready_for_picking(int row)
- {
- int counter = 0;
- for (int i = 0; i < size_of_plot; i++)
- {
- if (kiwiplot[row][i] > 5)
- {
- counter++;
- }
- }
- if (counter >= size_of_plot / 2)
- {
- return(true);
- }
- return(false);
- }
- void pick_kiwis(int row)
- {
- for (int i = 0; i < size_of_plot; i++)
- {
- if (kiwiplot[row][i] > 8)
- {
- rotten_counter++;
- }
- else if (kiwiplot[row][i] > 5)
- {
- good_counter++;
- }
- kiwiplot[row][i] = 0;
- }
- return;
- }
- void show_plot()
- {
- for (int i = 0; i < size_of_plot; i++)
- {
- for (int j = 0; j < size_of_plot; j++)
- {
- cout << kiwiplot[i][j] << " ";
- }
- cout << endl;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement