#include<iostream> #include<string> using namespace std; const int max_length=9; char c[10][10]={ "",//0 "",//1 "ABC",//2 "DEF",//3 "GHI",//4 "JKL",//5 "MNO",//6 "PQRS",//7 "TUV",//8 "WXYZ",//9 }; int total[10]={0,0,3,3,3,3,3,4,3,4}; int count=0; int main() { int number[max_length]={2,3,4}; int answer[max_length]={0}; int length=3; while(true) { for(int i=0;i<length;++i) cout<<c[number[i]][answer[i]]<<" "; count++; cout<<endl; int k=length-1; while(k>=0) { if(answer[k]<total[number[k]]-1) { answer[k]++; break; } else { answer[k]=0; k--; } } if(k<0) break; } cout<<count<<endl; system("pause"); return 0; }
时间: 2024-11-08 21:41:16