Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include <fstream>
- using namespace std;
- ofstream B;
- void func(int a){
- int sum = 0, max=0;
- while (a > 0){
- sum += a % 10;
- if (a % 10 > max){
- max = a % 10;
- }
- a /= 10;
- }
- B << " Сумма его цифр равна " << sum << " Максимальная цифра равна " << max << endl;
- }
- void main()
- {
- int chislo;
- setlocale(LC_ALL, "Rus");
- ifstream A;
- A.open("A.txt", ios::in);
- B.open("B.txt");
- while (!A.eof()){
- A >> chislo;
- B << "Само число " << chislo;
- func(chislo);
- }
- A.close();
- B.close();
- }
Advertisement
Add Comment
Please, Sign In to add comment