Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <math.h>
- #include <string>
- using namespace std;
- int SUMA_CYFR(int a);
- int main(){
- cout << SUMA_CYFR(123456789) << endl;
- cout << SUMA_CYFR(2159) << endl;
- cout << SUMA_CYFR(1221789) << endl;
- cout << SUMA_CYFR(12656789) << endl;
- cout << SUMA_CYFR(189) << endl;
- }
- int SUMA_CYFR(int a){
- string b = to_string(a);
- int c = 0;
- for (int i = 0; i < b.length(); i++) c += b[i] - '0';
- return c;
- }
Advertisement
Add Comment
Please, Sign In to add comment