fork download
  1. #include <iostream>
  2. #include <algorithm>
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7. string liczba = "123";
  8. int wynik = 0;
  9. for_each(liczba.begin(), liczba.end(), [&](char &znak){ wynik += znak - '0'; });
  10. cout << wynik << endl;
  11. return 0;
  12. }
Success #stdin #stdout 0s 3228KB
stdin
Standard input is empty
stdout
6