Skip to content

Instantly share code, notes, and snippets.

@swetarajbhar
Created November 1, 2020 11:48
Show Gist options
  • Save swetarajbhar/bba4fe5be7c371a4022265029ca51667 to your computer and use it in GitHub Desktop.
Save swetarajbhar/bba4fe5be7c371a4022265029ca51667 to your computer and use it in GitHub Desktop.
Chocolate and Wrapper Puzzle
#include<iostream>
using namespace std;
int totalchoc(int money,int price,int wrap)
{
if(money < price)
{
return 0;
}
int choc=money/price;
choc = choc+(choc-1)/(wrap-1);
return choc;
}
int main()
{
int money,price,wrap;
cout<<"Enter Money : ";
cin>>money;
cout<<"Enter Price Per Chocolate : ";
cin>>price;
cout<<"Enter Wrapper :";
cin>>wrap;
cout<<"Maximum Number of Chocolates = "<<totalchoc(money,price,wrap);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment