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 |
各位帮帮忙啊,还是Wrong Answer,谢谢了先!#include <stdio.h> #include <string.h> #include <math.h> static char source[2],dest[2],out[300]; void put(int num) { switch(num) { case 0: strcat(out,"0 0 0 0");break; case 1: strcat(out,"1 ");break; case 2: strcat(out,"2 ");break; case 3: strcat(out,"3 ");break; case 4: strcat(out,"4 ");break; case 5: strcat(out,"5 ");break; case 6: strcat(out,"6 ");break; case 7: strcat(out,"7 ");break; case 8: strcat(out,"8 ");break; case 9: strcat(out,"Inf");break; } } int main() { int n,i,num,ch,tmp,min; scanf("%d",&n); strcpy(out,""); for(i = 0;i < n;i++) { scanf("%s %s",source,dest); //处理 王 num = labs(source[0] - dest[0]); ch = labs(source[1] - dest[1]); if( (num == 0)&&(ch == 0) ) put(0); else { if(num > ch) min = ch; else min = num; tmp = min + labs(num - ch); put(tmp); //处理 后 if(num == ch) tmp = 1; else tmp = 2; put(tmp); //处理 车 tmp = 2; if((num == 0)||(ch == 0)) --tmp; put(tmp); //处理 象 if(num-ch) put(9); else put(1); } if(i != n - 1) { strcat(out,"\n"); } } puts(out); return 0; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator