The following program is my ACcepted code for UVA-10222.
It's a for everybody to learn and discuss.
If there is any mistake or comment, please let me know. :D
此乃UVA 10222 的AC code!
點這裡看題目 Click here to see this Problem!
//This program is for UVA 10222 Decode the Mad man
//題目來源 Problem link: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=14&page=show_problem&problem=1163
#include<stdio.h>
#include<string.h>
using namespace std;
char decode(char c)
{
char code[30] = {'d', 'm', 'b', 'g', 't', 'h', 'j', 'k', 'p', 'l', ';', '\'', '.', ',', '[', ']', 'e', 'y', 'f', 'u', 'o', 'n', 'r', 'v', 'i', 'c'};
if(c == ' ')
return ' ';
for(int i = 0; i <= 26; i++)
if( c == code[i] )
return 'a' + i;
}
int main()
{
char s[101];
while(gets(s) != NULL)
{
int len = strlen(s);
for(int i = 0; i < len; i++)
printf("%c", decode( s[i] ) );
printf("\n");
}
return 0;
}
Please feel free to use it after adding this blog as an reference. (http://autekroy.blogspot.tw)
If there is any mistake or comment, please let me know. :D
歡迎使用與分享任何內容,但請記得標示此部落格為出處。(http://autekroy.blogspot.tw/) 如果有發現任何的錯誤與建議請留言或跟我連絡。 : )
It's a for everybody to learn and discuss.
If there is any mistake or comment, please let me know. :D
此乃UVA 10222 的AC code!
歡迎一同討論學習,如有錯誤與任何建議請留言 : )
點這裡看題目 Click here to see this Problem!
//This program is for UVA 10222 Decode the Mad man
//題目來源 Problem link: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=14&page=show_problem&problem=1163
#include<stdio.h>
#include<string.h>
using namespace std;
char decode(char c)
{
char code[30] = {'d', 'm', 'b', 'g', 't', 'h', 'j', 'k', 'p', 'l', ';', '\'', '.', ',', '[', ']', 'e', 'y', 'f', 'u', 'o', 'n', 'r', 'v', 'i', 'c'};
if(c == ' ')
return ' ';
for(int i = 0; i <= 26; i++)
if( c == code[i] )
return 'a' + i;
}
int main()
{
char s[101];
while(gets(s) != NULL)
{
int len = strlen(s);
for(int i = 0; i < len; i++)
printf("%c", decode( s[i] ) );
printf("\n");
}
return 0;
}
歡迎使用與分享任何內容,但請記得標示此部落格為出處。(http://autekroy.blogspot.tw/) 如果有發現任何的錯誤與建議請留言或跟我連絡。 : )
沒有留言:
張貼留言
請留下您的任何想法或建議!
Please leave any thought or comment!