왜틀렸을까요?

jheee Reply 9 years 31 weeks ago
#include <stdio.h> #include<string.h> #include<math.h> int main() { int diu,a,b,i,m,k,t,r=0; char s1[1000]={0}; scanf("%d",&b); fflush(stdin); for(k=1;k<=b;++k) { gets(s1); for(i=0; i<strlen(s1); ++i) { if(('0'<=s1[i]&&s1[i]<='9')||('A'<=s1[i]&&s1[i]<='F')||('a'<=s1[i]&&s1[i]<='f')||(s1[i]=='x'||s1[i]=='X')) m=1; else { m=0; break; } } if(m==1) { if((s1[0]=='0')&&(s1[1]=='x'||s1[1]=='X')) { for(t=2;t<strlen(s1);t++) { double l=strlen(s1)-t-1; double z=pow(16,l); int w=(int)z; if('0'<=s1[t]&&s1[t]<='9') r+=w*(s1[t]-'0'); else if('A'<=s1[t]&&s1[t]<='F') r+=w*(s1[t]-'A'+10); else if('a'<=s1[t]&&s1[t]<='f') r+=w*(s1[t]-'a'+10); else { printf("null"); break; } } if(s1[t]!='x' &&s1[t]!='X') printf("%d",r); r=0; } else printf("null"); } else if(m==0) { printf("null"); } fflush(stdin); printf("\n"); } return 0; }