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 |
为什么总是WA,请各位牛歌牛姐们帮忙看看!!小女子比较苯,只好用苯的方法来做了! 请大家帮忙看看!!不胜感激!代码如下: #include<stdio.h> #include<string.h> void sort(char str[],int n) { int i; char temp; for(i=0;i<=(n-1)/2;i++) { temp=str[i]; str[i]=str[n-i-1]; str[n-i-1]=temp; } return; } int main() { int m,n,i,j,t; char a[]="FEDCBA98",b[9],c[9]; m=strlen(a); sort(a,m); while(EOF!=scanf("%s",b)) { n=strlen(b); sort(b,n); if(m>n) for(i=n;i<m;i++) b[i]='0'; else if(m==n&&strcmp(a,b)==0) { printf("0"); printf("\n"); } else if(m==n&&strcmp(a,b)< 0) break; else if(m<n) break; for(i=0;i<8;i++) { if(a[i]>b[i]) { if(a[i]>=65&&b[i]>=65) c[i]=a[i]-b[i]+'0'; if(a[i]>=65&&b[i]<65) { t=a[i]-'A'+10-(b[i]-'0'); if (t>=10) c[i]=t-10+'A'; else c[i]=t+'0'; } if(a[i]<65&&b[i]<65) c[i]=a[i]-b[i]+'0'; } else if(a[i]<b[i]) { a[i+1]-=1; if(a[i]>=64&&b[i]>=65) { t=16+a[i]-b[i]; if(t>=10) c[i]=t-10+'A'; else c[i]=t+'0'; } if(a[i]<64&&b[i]>=65) { t=16+a[i]-'0'-(b[i]-'A'+10); if(t>=10) c[i]=t-10+'A'; else c[i]=t+'0'; } if(a[i]<64&&b[i]<65) { t=16+a[i]-b[i]; if(t>=10) c[i]=t-10+'A'; else c[i]=t+'0'; } } else c[i]='0'; } sort(c,8); for(i=0;i<8;i++) if(c[i]!='0')break; for(j=i;j<8;j++) printf("%c",c[j]); 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