九宫格输入法
2023-08-06 16:06:42
发布于:浙江
#include<bits/stdc++.h>
using namespace std;
int pins[5];
int n;
void pin(string nowpin,int leftpin){
if(leftpin==0){
cout<<nowpin<<endl;
return;
}else{
if(pins[n-leftpin]==2){
pin(nowpin+"a",leftpin-1);
pin(nowpin+"b",leftpin-1);
pin(nowpin+"c",leftpin-1);
}else if(pins[n-leftpin]==3){
pin(nowpin+"d",leftpin-1);
pin(nowpin+"e",leftpin-1);
pin(nowpin+"f",leftpin-1);
}else if(pins[n-leftpin]==4){
pin(nowpin+"g",leftpin-1);
pin(nowpin+"h",leftpin-1);
pin(nowpin+"i",leftpin-1);
}else if(pins[n-leftpin]==5){
pin(nowpin+"j",leftpin-1);
pin(nowpin+"k",leftpin-1);
pin(nowpin+"l",leftpin-1);
}else if(pins[n-leftpin]==6){
pin(nowpin+"m",leftpin-1);
pin(nowpin+"n",leftpin-1);
pin(nowpin+"o",leftpin-1);
}else if(pins[n-leftpin]==7){
pin(nowpin+"p",leftpin-1);
pin(nowpin+"q",leftpin-1);
pin(nowpin+"r",leftpin-1);
pin(nowpin+"s",leftpin-1);
}else if(pins[n-leftpin]==8){
pin(nowpin+"t",leftpin-1);
pin(nowpin+"u",leftpin-1);
pin(nowpin+"v",leftpin-1);
}else if(pins[n-leftpin]==9){
pin(nowpin+"w",leftpin-1);
pin(nowpin+"x",leftpin-1);
pin(nowpin+"y",leftpin-1);
pin(nowpin+"z",leftpin-1);
}
}
}
int main(){
int sum=0;
cin>>n;
for(int i=0;i<n;i++){
cin>>pins[i];
if(i==0){
if(pins[i]==7 || pins[i]==9){
sum+=4;
}else{
sum+=3;
}
}else{
if(pins[i]==7 || pins[i]==9){
sum*=4;
}else{
sum*=3;
}
}
}
cout<<sum<<endl;
pin("",n);
return 0;
}
这里空空如也
有帮助,赞一个