--> Banknotes (beeCrowd- 1018) URI 1018 Solution C, Python | Alpha Codist

Search This Blog

Banknotes (beeCrowd- 1018) URI 1018 Solution C, Python

Banknotes beeCrowd- 1018 URI 1018 Solution C Python solved very easily neilor tonin uri int programming problem solving coding alpha codist easy py c

Banknotes

Banknotes beeCrowd- 1018 URI 1018 Solution C Python solved very easily neilor tonin uri int programming problem solving coding alpha codist easy py c

This problem is from beeCrowd. Here, You get the amount of money as input. It is an integer. You have to calculate and print the least amount of banknotes required to cover that much money. Banknotes, as given, are 100,50,20,10,5,2,1. 

The formula is:

  1. Take input.
  2. Create a list for banknotes and one for banknoteCount.
  3. Print the value of money.
  4. Start a for loop while checking for each note in banknotes.
  5. Run a while loop that checks if that particular note is >= inputted value.
  6. Add 1 to banknoteCount lists same index as the index of that note. Subtract notes amount from money.
  7. Print


The solution in C:


#include <stdio.h>

int main() {
 
    int money;
    scanf("%d",&money);
    int banknotes[7] = {100,50,20,10,5,2,1};
    int banknoteCount[7] = {};
    
    printf("%d\n",money);
    for(int i = 0; i<=6;i++){
        while(money>=banknotes[i]){
            banknoteCount[i]+=1;
            money-=banknotes[i];
        }
        printf("%d nota(s) de R$ %d,00\n",banknoteCount[i],banknotes[i]);
    }
    
 
    return 0;
}


The solution in Python:


money = int(input())

banknotes = [100,50,20,10,5,2,1]
banknoteCount = [0,0,0,0,0,0,0]

print("%d" % money)
for note in banknotes:
    while note <= money:
        banknoteCount[banknotes.index(note)]+=1
        money -= note
    print("%d nota(s) de R$ %d,00" % (banknoteCount[banknotes.index(note)],note))

COMMENTS

Name

beeCrowd,11,C,10,Computer,9,Downloads,3,HTML,1,My Creation,2,Python,24,Python-Soft,1,Shooting,2,
ltr
item
Alpha Codist: Banknotes (beeCrowd- 1018) URI 1018 Solution C, Python
Banknotes (beeCrowd- 1018) URI 1018 Solution C, Python
Banknotes beeCrowd- 1018 URI 1018 Solution C Python solved very easily neilor tonin uri int programming problem solving coding alpha codist easy py c
https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjDciR5EzWh0Wx74WeG72oHLrotueQLd6jRNI9grIE0PTLPJypwCKV-5jDHk-4pp_R5kA6mHBqo0EmJBxyeAOicuQ54eVAdlsvQ-HZb9IdR9gvZe1nQ75F8B7aLxCK_E9K4V5bStDWMJoRlT783w5KCqo7OgjGTzelt_dMe5MGNyFw9EnrvAFPLtYpZRw/w640-h422/1018.png
https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjDciR5EzWh0Wx74WeG72oHLrotueQLd6jRNI9grIE0PTLPJypwCKV-5jDHk-4pp_R5kA6mHBqo0EmJBxyeAOicuQ54eVAdlsvQ-HZb9IdR9gvZe1nQ75F8B7aLxCK_E9K4V5bStDWMJoRlT783w5KCqo7OgjGTzelt_dMe5MGNyFw9EnrvAFPLtYpZRw/s72-w640-c-h422/1018.png
Alpha Codist
https://alphacodist.blogspot.com/2022/11/banknotes1018.html
https://alphacodist.blogspot.com/
https://alphacodist.blogspot.com/
https://alphacodist.blogspot.com/2022/11/banknotes1018.html
true
7547834254111195316
UTF-8
Loaded All Posts Not found any posts VIEW ALL Readmore Reply Cancel reply Delete By Home PAGES POSTS View All RECOMMENDED FOR YOU LABEL ARCHIVE SEARCH ALL POSTS Not found any post match with your request Back Home Sunday Monday Tuesday Wednesday Thursday Friday Saturday Sun Mon Tue Wed Thu Fri Sat January February March April May June July August September October November December Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec just now 1 minute ago $$1$$ minutes ago 1 hour ago $$1$$ hours ago Yesterday $$1$$ days ago $$1$$ weeks ago more than 5 weeks ago Followers Follow THIS PREMIUM CONTENT IS LOCKED STEP 1: Share to a social network STEP 2: Click the link on your social network Copy All Code Select All Code All codes were copied to your clipboard Can not copy the codes / texts, please press [CTRL]+[C] (or CMD+C with Mac) to copy Table of Content