我的解法,循环了136次,可能多了点
#include "stdafx.h" #include <iostream> using namespace std; int _tmain(int argc, _TCHAR* argv[]) { unsigned char abPosition = 0x88; while (abPosition > 0) { if ( ((abPosition&0x0F) <9) && ((abPosition>>4) < 9) && ((abPosition&0x0F)%3 != (abPosition>>4)%3)) { cout << "A:" << (abPosition>>4); cout << " B:" << (abPosition&0x0F) << endl; } abPosition -= 1; } return 0; }