2014辽宁省ACM程序设计大赛网络赛 Problem A: Decryption

题目地址:http://acm.sau.edu.cn/JudgeOnline/problem.php?cid=1002&pid=0

问题 A: Decryption

时间限制: 1 Sec 内存限制: 32 MB
提交: 271 解决: 102

题目描述

Little A often receives some encrypted files, of which are all encrypted into 4-length integer (base 10), now he want to decrypt these files.

The roles of decrypting this file are as follows:

1. Translation all the 4-length integers into new numbers base 16.

2. Change the figures into characters as 0 to A, 1 to B, 2 to C…

For example: 2014(base 10) -> 7de(base 16) -> Hde

输入

There are several test cases.

For each test case, first line contains a positive integer N (N<=100), followed by N 4-length integers.

If N=0, stop read in.

输出

For each test case, output the information after decrypting. The output of one test case occupied exactly one line.

样例输入

3
1111 1987 6597
4
1485 1000 5987 4444
4
9999 9785 4737 19860

样例输出

EFHHcDBJcF
FcdDeIBHGDBBFc
CHAfCGDJBCIBHcC

提示


          题意:输入4位十进制数,转换成十六进制,并将0转换为A,1->B,2->C.....结果输出

 
//这道题考察10进制转换为16进制 
//刚比赛时我还没读完题,有人就做出来了~~
/***********************************
*
*	acm : hustoj-1010
*
*	title: Decryption
*
*	time : 2014.4.28
*
***********************************/

//考察10进制转化为16进制


#include <stdio.h>


int main()
{
	int n;
	int a;	
	int i;
	void D_X(int a);  //十进制转换为十六进制

	while (~scanf("%d", &n) && n!=0)
	{
		for (i=0; i<n; i++)
		{
			scanf("%d", &a);
			D_X(a);
		}
		printf("\n");
	}

	return 0;
}

void D_X(int a)
{
	int x[4];  //十六进制
	int i = 0;
	int j;
	char c;

	while (a != 0)
	{
		x[i] = a % 16;
		a = a / 16;
		i++;
	}

	for (j=i-1; j>=0; j--)
	{
		switch (x[j])
		{
		case 0: c = 'A';break;
		case 1: c = 'B';break;
		case 2: c = 'C';break;
		case 3: c = 'D';break;
		case 4: c = 'E';break;
		case 5: c = 'F';break;
		case 6: c = 'G';break;
		case 7: c = 'H';break;
		case 8: c = 'I';break;
		case 9: c = 'J';break;
		case 10: c = 'a';break;
		case 11: c = 'b';break;
		case 12: c = 'c';break;
		case 13: c = 'd';break;
		case 14: c = 'e';break;
		case 15: c = 'f';break;
		}

		printf("%c", c);
	}
}





 
 
 
 
 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值