Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
伤不起的看我的代码,你就欣慰了#include<stdio.h> #include<string.h> char s[17][5]={ "0000","0001","0010","0011", "0100","0101","0110","0111", "1000","1001","1010","1011", "1100","1101","1110","1111" }; int main() { char R[32]="00000000"; char tR[32]; int X,Y; char T[128]; int i,j,k; i = 0; while(scanf("%c",&tR[i]),tR[i++]!=','); i--; j = 8-i; k = 0; for(i=j;i<8;i++)R[i] = tR[k++]; scanf("%d,%d",&X,&Y); int end = 8 * 4 - 1; for(i=0;i<8;i++) { for(j=0;j<4;j++) { if('0'<= R[i] && R[i]<='9') k = R[i] - '0'; else k = R[i] - 'a' + 10; T[i*4+j] = s[k][j]; } } T[end-X] = '0'; T[end-Y] = '1'; T[end-Y+1] = '1'; T[end-Y+2] = '0'; int m,n; for(i=0;i<8;i++) { m=0; n=1; for(j=0;j<4;j++) { m += (T[i*4+3-j]-'0')*n; n*=2; } if(0 <= m && m <= 9) R[i] = m + '0'; else R[i] = 'a' + (m - 10); } for(i=0;i<8;i++)if(R[i]!='0')break; for(;i<8;i++)printf("%c",R[i]); printf("\n"); return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator