2 条题解

  • 1
    @ 2025-8-3 14:45:04
    #include<bits/stdc++.h>
    using namespace std;
    long long n,a[100000000],i;
    int main(){
    	cin >> n;
    	if(n==0) {
    		cout << "0";
    		return 0;
    	}
    	while (n){
    		a[++i]=n%16;
    		n/=16;
    	}
    	for(int j=i; j>=1; j--){
    		if(a[j]<10) cout << a[j];
    		else cout << char(a[j]-10+'A');
    		}
            
    	return 0;
    }
    
    • 1
      @ 2023-6-10 18:41:12
      #include <iostream>
      #include <stack>
      using namespace std;
      int main()
      {
      	int num;
      	cin >> num;
      	if(num == 0){
      		cout << 0;
      			return 0;
      	}
      	stack<char> s;
      	while (num)
      	{
      		int temp = num % 16;
      		if (temp < 10)
      		{
      			s.push(temp + '0');
      		}
      		else
      		{
      			s.push(temp - 10 + 'A');
      		}
      		num /= 16;
      	}
      	while (!s.empty())
      	{
      		cout << s.top();
      		s.pop();
      	}
      	return 0;
      }
      
      • 1

      信息

      ID
      1212
      时间
      1000ms
      内存
      128MiB
      难度
      6
      标签
      (无)
      递交数
      62
      已通过
      20
      上传者