Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- #include <algorithm>
- #include <vector>
- using namespace std;
- int k;
- int zbir(int broj) {
- if(broj == 0) {
- return 0;
- }
- int cifra = broj % 10;
- int result = 0;
- if(cifra > k) {
- result = zbir(broj / 10) + cifra;
- cout << cifra;
- }
- else {
- result = zbir(broj / 10);
- }
- return result;
- }
- int main() {
- cin >> k;
- int n;
- cin >> n;
- for(int i = 0; i < n; i++) {
- int broj;
- cin >> broj;
- int result = zbir(broj);
- cout << ":" << result << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement