Advertisement
madalinaradu

ASD Pb 11 bancnote

May 26th, 2019
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.88 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<conio.h>
  3. #include<stdbool.h>
  4. #include<iostream>
  5.  
  6. using namespace std;
  7.  
  8.  
  9. int calculPutere(int x,int exp){
  10.     int p=1;
  11.     for(int i=1; i<=exp; i++){
  12.         p=p*x;
  13.     }
  14.    return p;
  15. }
  16.  
  17. int rest(int s, int n, int e){
  18.     int moneda=calculPutere(e,n);
  19.     while(moneda>s){
  20.             moneda=moneda/e;
  21.     }
  22.     cout<<endl;
  23.     cout<<moneda;
  24.     cout<<endl;
  25.     return moneda;
  26. }
  27.  
  28. int plataSuma(int s, int n, int e){//n exponent, e baza, s suma de platit
  29.     int moneda=rest(s,n,e);
  30.     int totalMonede=0;
  31.     while(s>0){
  32.         cout<<s/moneda<<" Monede de "<< moneda<<endl;
  33.         totalMonede=totalMonede +s/moneda;
  34.         s=s%moneda;
  35.         moneda=rest(s,n,e);
  36.     }
  37.     return totalMonede;
  38. }
  39. int main(){
  40.     int s=444;
  41.     int e=2;
  42.     int n=5;
  43.     cout<<"Au fost folosite "<<plataSuma(s,n,e)<<" monede.";
  44.     return 0;
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement