English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
تقديم مجموعة من البيانات، تتكون من استثمارات العديد من الأشخاص، ومجموعة أخرى تحتوي على فترات استثمار العملات للناس، مهمة إنشاء معدل توزيع الأرباح.
在合伙公司中,合伙人应根据合伙人在企业中投入的资金来分配盈亏。根据该资本投资百分比,我们计算出利润分配比率,该比率显示了将要提供给每个业务合作伙伴的利润额。
公式-合作伙伴1 = 投资资金*时间段
合作伙伴2 = 投资资金*时间段
合作伙伴3 = 投资资金*时间段
合作伙伴4 = 投资资金*时间周期。。
人n = 投资资本*时间段
利润分享率=合作伙伴1:合作伙伴2:合作伙伴3
Input-: amount[] = {1000, 2000, 2000} time[] = {2, 3, 4} Output-: profit sharing ratio 1 : 3 : 4 Input-: amount[] = {5000, 6000, 1000} time[] = {6, 6, 12} Output-: profit sharing ratio 5 : 6 : 2
我们将用来解决给定问题的方法
将输入作为多个合作伙伴投入的资本数组,以及他们投入该资本的时间段的另一个数组
将一位合伙人的资本乘以其相应的时间段,然后与另一位合伙人重复
计算乘积比
显示最终结果
Start step 1-> declare function to calculate GCD- int GCD(int arr[], int size) declare int i Declare int result = arr[0] Loop For i = 1 and i < size and i++ set result = __gcd(arr[i], result) نهاية return result step 2-> declare function to calculate profit sharing rate void cal_ratio(int amount[], int time[], int size) declare int i, arr[size] Loop For i = 0 and i < size and i++ set arr[i] = amount[i] * time[i] نهاية declare int ratio = GCD(arr, size) Loop For i = 0 and i < size - 1 and i++ طبع arr[i] / ratio نهاية طبع arr[i] / ratio خطوة 3-> في main() إعلان int amount[] = { 1000, 2000, 2000 } إعلان int time[] = { 2, 3, 4 } حساب int size = sizeof(amount) / sizeof(amount[0]) إتصال cal_ratio(amount, time, size) توقف
#include <bits/stdc++.h> using namespace std; // حساب أكبر عدد مشترك int GCD(int arr[], int size) { int i; int result = arr[0]; for (i = 1; i < size; i++) result = __gcd(arr[i], result); عدد result; } // حساب نسبة مشاركة الربح void cal_ratio(int amount[], int time[], int size) { int i, arr[size]; for (i = 0; i < size; i++) arr[i] = amount[i] * time[i]; int ratio = GCD(arr, size); for (i = 0; i < size - 1; i++) cout << arr[i] / ratio << " : "; cout << arr[i] / ratio; } int main() { int amount[] = { 1000, 2000, 2000 }; int time[] = { 2, 3, 4 }; int size = sizeof(amount) / sizeof(amount[0]); cout << "نسبة مشاركة الربح "; cal_ratio(amount, time, size); عدد 0; }
نتيجة الإخراج
نسبة مشاركة الربح 1 : 3 : 4