Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- int rekurzija(int broj, int K) {
- if(broj == 0) {
- return 0; // base case, ne prodolzuvaj ponatamu
- }
- int digit = (broj % 10);
- int ret = 0;
- if(digit > K) {
- ret = rekurzija(broj / 10, K) + digit;
- printf("%d", digit);
- }
- else {
- ret = rekurzija(broj / 10, K);
- }
- return ret;
- }
- int main()
- {
- int K, N;
- scanf("%d%d", &K, &N);
- for(int i = 0; i < N; i++) {
- int broj;
- scanf("%d", &broj);
- int suma = rekurzija(broj, K);
- printf(" : %d\n", suma);
- }
- return 0;
- }
- /*
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement