Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- int CountProductsAveragePrice(int prices[], int count)
- {
- int total = 0;
- for (int i = 0; i < count; i++)
- {
- total += prices[i];
- }
- return total / count;
- }
- double CountProductsTotalWeight(int weights[], int count)
- {
- double total = 0;
- for (int i = 0; i < count; i++)
- {
- total += weights[i];
- }
- return total / 1000;
- }
- int main()
- {
- int productsCount = 3, canCarry = 2;
- int productPrice[productsCount], productWeight[productsCount];
- productPrice[0] = 10, productWeight[0] = 700;
- productPrice[1] = 10, productWeight[1] = 700;
- productPrice[2] = 10, productWeight[2] = 700;
- double totalWeight = CountProductsTotalWeight(productWeight, productsCount);
- std::cout << "Vidutinė prekių kaina centais yra " << CountProductsAveragePrice(productPrice, productsCount) << std::endl;
- if (totalWeight > canCarry)
- {
- std::cout << "Saulius visų pirkinių parnešti negalės.";
- }
- else
- {
- std::cout << "Saulius galės parnešti visus pirkinius.";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement