Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#include <stdio.h>
int s, n, vrNov[10], brNov[10];
void Ispis() {
for(int i = 0; i < n; i++)
printf("%d novcanica od %d din ", brNov[i], vrNov[i]);
printf("\n");
}
void Rasitni(int indNov, int suma){
if(indNov >= n){
if(suma == 0) Ispis();
}
else {
for(int i = 0; i <= suma / vrNov[indNov]; i++){
brNov[indNov] = i;
Rasitni(indNov + 1, suma - vrNov[indNov] * brNov[indNov]);
}
}
}
main() {
printf("Br. razlicitih novcanica: \t");
scanf("%d", &n);
printf("Suma: \t");
scanf("%d", &s);
for(int i = 0; i < n; i++)
scanf("%d", &vrNov[i]);
Rasitni(0, s);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.