Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
Register

## 看见前面几位前辈，我连死的心也有！！！

Posted by dogdoghao at 2013-09-14 09:49:41 on Problem 3748
```#include <stdio.h>

int b=8;

char H[9];
int x=0;
int y=0;
char B[33];

//数据输入函数
void scan () {

scanf ("%[0-9a-fA-F]s", &H);
getchar();
scanf ("%d,%d", &x, &y);
}

//输入数据不足8位处理
void p1 () {

int w;
for (w=0; ;w++) if (H[w]=='\0') break;
for (int j=0; j<8-w; j++) {
for (int i=6; i>=0; i--) H[i+1] = H[i];
H[0] = '0';
}
H[8] = '\0';
//printf("%s\n", H);
}

//16进制向2进制转换
void H2B () {

char temp;
int i;
for (i=0; H[i]!='\0' ; i++) {

temp = H[i];
switch (temp) {
case '0': B[i*4+0]='0';B[i*4+1]='0';B[i*4+2]='0';B[i*4+3]='0';	break;
case '1': B[i*4+0]='0';B[i*4+1]='0';B[i*4+2]='0';B[i*4+3]='1';	break;
case '2': B[i*4+0]='0';B[i*4+1]='0';B[i*4+2]='1';B[i*4+3]='0';	break;
case '3': B[i*4+0]='0';B[i*4+1]='0';B[i*4+2]='1';B[i*4+3]='1';	break;
case '4': B[i*4+0]='0';B[i*4+1]='1';B[i*4+2]='0';B[i*4+3]='0';	break;
case '5': B[i*4+0]='0';B[i*4+1]='1';B[i*4+2]='0';B[i*4+3]='1';	break;
case '6': B[i*4+0]='0';B[i*4+1]='1';B[i*4+2]='1';B[i*4+3]='0';	break;
case '7': B[i*4+0]='0';B[i*4+1]='1';B[i*4+2]='1';B[i*4+3]='1';	break;
case '8': B[i*4+0]='1';B[i*4+1]='0';B[i*4+2]='0';B[i*4+3]='0';	break;
case '9': B[i*4+0]='1';B[i*4+1]='0';B[i*4+2]='0';B[i*4+3]='1';	break;
case 'A':
case 'a': B[i*4+0]='1';B[i*4+1]='0';B[i*4+2]='1';B[i*4+3]='0';	break;
case 'B':
case 'b': B[i*4+0]='1';B[i*4+1]='0';B[i*4+2]='1';B[i*4+3]='1';	break;
case 'C':
case 'c': B[i*4+0]='1';B[i*4+1]='1';B[i*4+2]='0';B[i*4+3]='0';	break;
case 'D':
case 'd': B[i*4+0]='1';B[i*4+1]='1';B[i*4+2]='0';B[i*4+3]='1';	break;
case 'E':
case 'e': B[i*4+0]='1';B[i*4+1]='1';B[i*4+2]='1';B[i*4+3]='0';	break;
case 'F':
case 'f': B[i*4+0]='1';B[i*4+1]='1';B[i*4+2]='1';B[i*4+3]='1';	break;
default : printf("error\n");
}
}
B[i*4] = '\0';
}

//X,Y置换
void trans () {

B[31-x]   = '0';
B[31-y]   = '1';
B[31-y+1] = '1';
B[31-y+2] = '0';
}

//2进制向16进制转换
void B2H () {

int temp;
int i;
for (i=0; B[i]!='\0'; i+=4) {
H[i/4] = '0';
for (int j=0,k=8; j<4; j++,k=k/2) {
if (B[i+j] == '1') H[i/4] = H[i/4] + k;
}
if (H[i/4] > '9') H[i/4] = H[i/4] + 'a' - '9' - 1;
}
H[i/4] = '\0';
}

//输出数据规格化
void p2 () {

for (int i=0; i<7&&H[0]=='0'; i++)
for (int j=0; j<8; j++) H[j] = H[j+1];
}

//数据输出
void print () {

//printf("%s\n", B);
//printf("%x\n", x);
//printf("%d\n", y);
printf("%s\n", H);

}

//主函数
void main () {

scan();
p1();
H2B();
trans();
B2H();
p2();
print();

}```

Followed by: