ChameL1oN

Untitled

Dec 1st, 2014
234
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. #include<iostream>
  2. #include <fstream>
  3. using namespace std;
  4.  
  5. ofstream B;
  6.  
  7. void func(int a){
  8. int sum = 0, max=0;
  9. while (a > 0){
  10. sum += a % 10;
  11. if (a % 10 > max){
  12. max = a % 10;
  13. }
  14. a /= 10;
  15. }
  16. B << " Сумма его цифр равна " << sum << " Максимальная цифра равна " << max << endl;
  17. }
  18.  
  19. void main()
  20. {
  21. int chislo;
  22. setlocale(LC_ALL, "Rus");
  23. ifstream A;
  24. A.open("A.txt", ios::in);
  25. B.open("B.txt");
  26. while (!A.eof()){
  27. A >> chislo;
  28. B << "Само число " << chislo;
  29. func(chislo);
  30. }
  31. A.close();
  32. B.close();
  33. }
Advertisement
Add Comment
Please, Sign In to add comment