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 b){
- int ostatok;
- int *pRezults;
- int countnum = 1;
- int temp = a;
- while (temp /= b)
- ++countnum;
- pRezults = new int[countnum];
- pRezults[0] = 0;
- temp = 0;
- while (a)
- {
- ostatok = a % b;
- a /= b;
- pRezults[temp++] = ostatok;
- }
- for (int i = countnum - 1; i >= 0; --i)
- {
- B << pRezults[i];
- }
- B << endl;
- }
- int main()
- {
- setlocale(LC_ALL, "Rus");
- int chislo,w;
- ifstream A;
- A.open("A.txt", ios::in);
- B.open("C.txt");
- cout << "Введите необходимую систему счисления";
- cin >> w;
- while (!A.eof()){
- A >> chislo;
- func(chislo, w);
- }
- A.close();
- B.close();
- }
Advertisement
Add Comment
Please, Sign In to add comment