Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- using namespace std;
- ofstream B;
- // Перевести число в систему P<10
- void func(int c, int w)
- {
- int n = 1, j = c;
- int b = 0;
- B << "Число в нужной системе счисления = ";
- while (c >= w){
- c /= w;
- }
- while (j >= w){
- b += j%w * n;
- j /= w;
- n *= 10;
- }
- b += c * n;
- cout << b;
- B << b;
- cout << endl;
- }
- void main()
- {
- setlocale(LC_ALL, "rus");
- int a;
- int q;
- ifstream A;
- cout << "Введите нужную систему счисления";
- cin >> q;
- A.open("A.txt", ios::in);
- B.open("B.txt");
- while (!A.eof())
- {
- A >> a;
- B << "Начально число = " << a << " ";
- func(a, q);
- B << " " << endl;
- }
- A.close();
- B.close();
- }
Advertisement
Add Comment
Please, Sign In to add comment