Created
November 8, 2016 17:46
-
-
Save splitline/3cf99b9bafd3d47c634f2aa46e8210f1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
#include <math.h> | |
char word[10][4]={{},{},{"ABC"},{"DEF"},{"GHI"},{"JKL"},{"MNO"},{"PRS"},{"TUV"},{"WXY"}}; | |
int main(){ | |
char in[105]; | |
while(gets(in)!=NULL){ | |
int len=strlen(in),flag=0,numl; | |
char num[8]; | |
memset(num,0,sizeof(num)); | |
for(int i=0,j=0;i<len;i++){ | |
if(in[i]<='9'&&in[i]>='2'){ | |
flag=1; | |
num[j++]=in[i]; | |
numl=j; | |
if(j>=7)break; | |
} | |
if(in[i]=='0'||in[i]=='1'){ | |
flag=-1; | |
break; | |
} | |
} | |
if(flag==-1){ | |
printf("Can't print a word!\n"); | |
memset(in,0,sizeof(in)); | |
continue; | |
} | |
if(flag==0){ | |
printf("None.\n"); | |
memset(in,0,sizeof(in)); | |
continue; | |
} | |
char out[2200][8]={0}; | |
//開始填入 | |
int t=pow(3,numl),tt=t,word_p=0; | |
for(int p=0;p<numl;p++){ | |
for(int i=0;i<t;i++){ | |
out[i][p]=word[num[p]-'0'][word_p%3]; | |
if((i+1)%(tt/3)==0)word_p++; | |
} | |
tt=tt/3; | |
} | |
//結束填入 | |
for(int i=0;i<t;i++) | |
printf("%s\n",out[i]); | |
memset(in,0,sizeof(in)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment