zoukankan      html  css  js  c++  java
  • 十进制转十进制以下的其他进制

    //十进制转十进制以下的其他进制
    #include <iostream>
    #include <stack>
    using namespace std;
    
    int main()
    {
    	int T;
    	int n, a, p;
    	cin >> T;
    	while (T--)
    	{
    		stack<int> s; 
    		//n 为十进制,p为要转换的进制
    		cin >> n >> p;
    		while (n)
    		{
    			a = n % p;
    			s.push(a);
    			n /= p;
    		}
    		while (!s.empty())
    		{
    			cout << s.top();
    			s.pop();
    		}
    		cout << endl;
    	}
    	system("pause");
    	return 0;
    }
    

    运行测试:

    感谢阅读,如有问题,请批评指正,谢谢。
  • 相关阅读:
    【心情】codeforces涨分啦!
    redis
    rabbitmq
    lucene
    MongoDB
    负载均衡
    分布式存储
    Memcache
    websocket
    Remoting
  • 原文地址:https://www.cnblogs.com/clwsec/p/11565447.html
Copyright © 2011-2022 走看看