Last active
January 21, 2022 16:47
-
-
Save 08shubhamjindal/8533a9565f1bbc450fe006f4c1a2154a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<bits/stdc++.h> | |
using namespace std; | |
int main(){ | |
int listofusers[6] = {1,2,3,4,5,6}; | |
int v[7][7] = {0}; | |
int t; | |
cin>>t; | |
while(t--){ | |
int paidByUserId,amountPaid,countofIdWhoOws; | |
cin>>paidByUserId>>amountPaid>>countofIdWhoOws; | |
int paidforUserIds[countofIdWhoOws]; | |
int amountforUserIds[countofIdWhoOws]; | |
string typeofPayment; | |
cin>>typeofPayment; | |
for(int i=0; i<countofIdWhoOws; i++){ | |
cin>>paidforUserIds[i]; // 2,3 // 1,2 | |
} | |
if(typeofPayment != "Equal"){ | |
for(int i=0; i<countofIdWhoOws; i++){ | |
cin>>amountforUserIds[i]; // 400 //600 // 1500 //500 | |
} | |
} | |
if(typeofPayment=="Exact"){ | |
for(int i=0; i<countofIdWhoOws; i++){ | |
v[paidByUserId][paidforUserIds[i]] = v[paidByUserId][paidforUserIds[i]] + amountforUserIds[i]; | |
} | |
} | |
else if(typeofPayment == "Percent"){ | |
for(int i=0; i<countofIdWhoOws; i++){ | |
v[paidByUserId][paidforUserIds[i]] = v[paidByUserId][paidforUserIds[i]] + (amountPaid * amountforUserIds[i])/100; | |
} | |
} | |
else{ | |
for(int i=0; i<countofIdWhoOws; i++){ | |
v[paidByUserId][paidforUserIds[i]] = v[paidByUserId][paidforUserIds[i]] + (amountPaid/countofIdWhoOws); | |
} | |
} | |
} | |
cout<<v[1][2]<<endl; | |
cout<<v[2][1]<<endl; | |
int checkUserId; | |
cin>>checkUserId; | |
for(int i=0; i<6; i++){ | |
if(checkUserId!=listofusers[i]){ | |
if(v[checkUserId][listofusers[i]]-v[listofusers[i]][checkUserId]<0){ | |
cout<<checkUserId<<" will give to this amount "<<abs(v[checkUserId][listofusers[i]]-v[listofusers[i]][checkUserId])<<"to user"<<listofusers[i]<<endl; | |
}else if(v[checkUserId][listofusers[i]]-v[listofusers[i]][checkUserId]>0){ | |
cout<<checkUserId<<" owes of this amount "<<v[checkUserId][listofusers[i]]-v[listofusers[i]][checkUserId]<<" from userr"<<listofusers[i]<<endl; | |
}else{ | |
cout<<"nikal "<<listofusers[i]<<endl; | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
5
1 1200 2 Exact 2 3 200 1000
1 1000 3 Exact 1 2 4 200 200 600
2 2000 2 Exact 1 4 500 1500
4 2000 4 Exact 1 2 5 4 500 200 1000 300
1 1000 5 Exact 1 2 3 4 5 200 200 200 200 200
1