কম্পিউটার

C++ এ প্রয়োজনীয় কারেন্সি নোটের সংখ্যা গণনা করুন


টাকায় একটি পরিমাণ দেওয়া যা একজনকে দিতে হবে, বলুন pay_rupees এবং সীমাহীন পরিমাণ ব্যাঙ্কনোট যার মূল্য Rupees_amount_1 এবং Rupees_amount_2। লক্ষ্য হল নোটের মোট সংখ্যা=বন্টন_মোট ব্যবহার করে pay_rupees প্রদান করা এবং প্রয়োজনীয় Rupees_amount_1 নোটের সংখ্যা গণনা করা। যদি অর্থ প্রদানের কোন সমাধান না থাকে তবে উত্তর হিসাবে −1 ফেরত দিন।

উদাহরণস্বরূপ

ইনপুট

Rupees_amount_1 = 1, Rupees_amount_2 = 5, pay_Rupees = 11 distribution_total = 7

আউটপুট

Count of number of currency notes needed are − 6

ব্যাখ্যা

6*1 + 5*1 = 11 and notes=6+1=7

ইনপুট

Rupees_amount_1 = 2, Rupees_amount_2 = 3, pay_Rupees = 10 distribution_total = 4

আউটপুট

Count of number of currency notes needed are: 2

ব্যাখ্যা

2*2 + 3*2 = 10 and notes=2+2=4

নিম্নলিখিত প্রোগ্রামে ব্যবহৃত পদ্ধতি

ধরা যাক a1 হল 1 টাকার নোটের সংখ্যা এবং N হল মোট নোটের সংখ্যা। P-এর অর্থপ্রদান করতে, আমাদের সমীকরণ থাকবে −a1*(Rupees_amount_1) + (N−a1)*(Rupees_amount_2) =P P=a1*(Rupees_amount_1) + (N)*(Rupees_amount_2) − (a1)*(Rupees_amount_2) ) P − (N)*(Rupees_amount_2) =a1*(Rupees_amount_1) − (a1)*(Rupees_amount_2) a1=P − (N)*(Rupees_amount_2) / ( Rupees_amount_1 − Rupees_amount-এর মধ্যে থাকলে 2_amount হবে) একটি সমাধান অন্যথায় −1 ফেরত দিন।

  • ইনপুট হিসাবে সমস্ত সংখ্যা নিন।

  • ফাংশন notes_needed(int Rupees_amount_1, int Rupees_amount_2, intpay_Rupees, int distribution_total) সমস্ত ইনপুট নেয় এবং প্রয়োজনীয় কারেন্সি নোটের সংখ্যা ফেরত দেয়।

  • 0 হিসাবে প্রাথমিক গণনা নিন।

  • মোট নিন =বেতন_রুপি − (রূপী_অর্থ_২ * বিতরণ_মোট)

  • মোট_প্রদত্ত =রুপি_অ্যামাউন্ট_1 − রুপি_অর্থ_2

    সেট করুন
  • মোট_প্রদত্ত =রুপি_অ্যামাউন্ট_1 − রুপি_অর্থ_2

    সেট করুন
  • যদি মোট % total_given ==0 হয় তাহলে ফেরত গণনা মোট / total_given।

  • অন্যথায় −1 ফেরত।

উদাহরণ

#include<bits/stdc++.h>
using namespace std;
int notes_needed(int Rupees_amount_1, int Rupees_amount_2, int pay_Rupees, int
distribution_total){
   int count = 0;
   int total = pay_Rupees − (Rupees_amount_2 * distribution_total);
   int total_given = Rupees_amount_1 − Rupees_amount_2;
   if (total % total_given == 0){
      count = total / total_given;
      return count;
   } else {
      return −1;
   }
}
int main(){
   int Rupees_amount_1 = 1;
   int Rupees_amount_2 = 5;
   int pay_Rupees = 11;
   int distribution_total = 7;
   cout<<"Count of number of currency notes needed are: "<<notes_needed(Rupees_amount_1, Rupees_amount_2, pay_Rupees, distribution_total);
}

আউটপুট

যদি আমরা উপরের কোডটি চালাই তবে এটি নিম্নলিখিত আউটপুট −

উৎপন্ন করবে
Count the number of currency notes needed are− 6

  1. কয়েন পরিশোধ করে n এ পৌঁছানোর জন্য প্রয়োজনীয় অপারেশনের সংখ্যা গণনা করার জন্য C++ প্রোগ্রাম

  2. কিভাবে C++ ব্যবহার করে OpenCV-তে মুখের সংখ্যা গণনা করবেন?

  3. কিভাবে C++ ব্যবহার করে ওপেনসিভিতে ফ্রেমের মোট সংখ্যা গণনা করবেন?

  4. নোডগুলি গণনা করুন যার সমষ্টি X এর সাথে C++ এ একটি ফিবোনাচি সংখ্যা