Skip to content

Instantly share code, notes, and snippets.

@rista404
Created April 2, 2016 10:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rista404/bddf17cc1ccc1c5b99bba6b1501df788 to your computer and use it in GitHub Desktop.
Save rista404/bddf17cc1ccc1c5b99bba6b1501df788 to your computer and use it in GitHub Desktop.
#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