#include <stdio.h>
int main ()
{ int a,s,t,i,b[100],j; scanf("%d",&t); for(i=0;i<t;i++) { scanf("%d",&a); s=a%10; switch(s) { case 0:b[i]=0; break; case 1:b[i]=1; break; case 2: j=a%4; switch(j) { case 0:b[i]=6; break; case 1:b[i]=2; break; case 2:b[i]=4; break; case 3:b[i]=8; break; } break; case 3:j=a%4; switch(j) { case 0:b[i]=1; break; case 1:b[i]=3; break; case 2:b[i]=9; break; case 3:b[i]=7; break; } break; case 4:j=a%2; switch(j) { case 0:b[i]=6; break; case 1:b[i]=4; break; } break; case 5:b[i]=5; break; case 6:b[i]=6; break; case 7:j=a%4; switch(j) { case 0:b[i]=1; break; case 1:b[i]=7; break; case 2:b[i]=9; break; case 3:b[i]=3; break; } break; case 8: j=a%4; switch(j) { case 0:b[i]=6; break; case 1:b[i]=8; break; case 2:b[i]=4; break; case 3:b[i]=2; break; } break; case 9: j=a%2; switch(j) { case 0:b[i]=1; break; case 1:b[i]=9; break; } } printf("%d\n",b[i]); }
return 0;
}
楼主的代码我这样改了下,你看下吧。