蛮简单的一道题,10进制转2进制,然后数组操作就OK了..... // source code of submission 734146, Zhongshan University Online Judge System #include <iostream> #include <cstring> #include <cstdio> using namespace std; int main() { int n,i,j,h,m,s; int ver[6][3],hor[3][6]; int data_set = 1; cin>>n; while(n--) { memset(ver,0,sizeof(ver)); memset(hor,0,sizeof(hor)); scanf("%d:%d:%d",&h,&m,&s); i = 5; while(h) { ver[i][0] = h % 2; hor[0][i] = h % 2; h /= 2,i--; } i = 5; while(m) { ver[i][1] = m % 2; hor[1][i] = m % 2; m /= 2,i--; } i = 5; while(s) { ver[i][2] = s % 2; hor[2][i] = s % 2; s /= 2,i--; } cout<<data_set<<" "; for(i = 0;i<6;i++) for(j = 0;j<3;j++) cout<<ver[i][j]; cout<<" "; for(i = 0;i<3;i++) for(j = 0;j<6;j++) cout<<hor[i][j]; cout<<endl; data_set++; } return 0; }