fork download
  1. #include <iostream>
  2. #include <string>
  3. using namespace std;
  4. unsigned long N(string text)
  5. {
  6. int i = 0;
  7. int sum = 0;
  8. while(text[i++] != 0) {
  9. sum += atoi(&text[i]);
  10.  
  11. }
  12. return (sum/2);
  13. }
  14.  
  15. int main() {
  16. string text1;
  17. getline(cin,text1);
  18. string text2;
  19. getline(cin,text2);
  20. int ch1 = N(text1);
  21. int ch2 = N(text2);
  22.  
  23. cout << ch1 << endl;
  24. cout << ch2 << endl;
  25. if (ch1 > ch2)
  26. cout << "1" << " ";
  27. else if (ch1 < ch2)
  28. cout << "2" ;
  29. else
  30. cout << "Равны";
  31. return 0;
  32. }
Success #stdin #stdout 0s 15240KB
stdin
Zdravstvuite
S novim 2007 godom
stdout
0
2017
2