Submission

Status:

----------

Subtask/Task Score:

0/100

Score: 0

User: santanaja07

Problemset: แปลงเลขฐาน

Language: cpp

Time: 0.003 second

Submitted On: 2025-09-21 20:42:12

#include <iostream>
#include <string>
#include <math.h>
using namespace std;

int main() 
{
    string c;
    cin>>c;
    int eight,two,ten;
    int t=1;
    ten=0;
    for(int i=0;i<c.length();i++){
    	if('0'<=c[i]&&c[i]<='9'){
    		ten+=(c[i]-'0')*pow(16,c.length()-i-1);
		}else if('A'<=c[i]&&c[i]<='F'){
    		ten+=(c[i]-'A'+10)*pow(16,c.length()-i-1);
		}
	}
	cout<<ten<<endl;
    int copyten;
    copyten=ten;
    string strtwo="",streight="";
	while(ten>0){
		strtwo= char(ten%2+'0') + strtwo;
		ten=ten/2;
	}
	
	while(copyten>0){
		streight= char(copyten%8+'0') + streight;
		copyten=copyten/8;
	}
	cout<<strtwo<<endl;
	cout<<streight;
	
    return 0;
}