ChameL1oN

Untitled

Nov 28th, 2014
246
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. using namespace std;
  4.  
  5. ofstream B;
  6.  
  7. void func(int &c , int w)
  8. {
  9. int b=0,n=1,k=c;
  10. B << "Число в нужной системе счисления = ";
  11. if (c >= w){
  12. while (c >= w)
  13. {
  14.  
  15. b = b*10 + (c%w * n);
  16. c /= w;
  17. n *= 10;
  18. }
  19. B << c;
  20. do{
  21. B << b % 10;
  22. b /= 10;
  23. } while (b > 0);
  24. B << endl;
  25. }
  26. else
  27. B << c << "\n";
  28. }
  29.  
  30. void main()
  31. {
  32. setlocale(LC_ALL, "rus");
  33. int a;
  34. int q;
  35. ifstream A;
  36. cout << "Введите нужную систему счисления";
  37. cin >> q;
  38. A.open("A.txt", ios::in);
  39. B.open("B.txt");
  40. while (!A.eof())
  41. {
  42. A >> a;
  43. B << "Начально число = " << a << "\n";
  44. func(a,q);
  45. }
  46. A.close();
  47. B.close();
  48. }
Advertisement
Add Comment
Please, Sign In to add comment