初学者_摩斯密码转换'
本帖最后由 Adley 于 2015-11-30 17:27 编辑新手不知道哪里错了,求高手。
1代表' . ’ 2代表’ — ’ 看来只能自问自答了
#include "stdafx.h"
#include "stdlib.h"
void main()
{
int a_0[] = { 12, 2111, 2121, 211, 1, 1121, 221, 1111, 11, 1222, 212, 1211, 22, 21, 222, 1221, 2212, 121, 111, 2, 112, 1112, 122, 2112, 2122, 2211 };
int a_1[] = { 22222, 12222, 11222, 11122, 11112, 11111, 21111, 22111, 22211, 22221 };
int a_2[] = { 2212, 11, 21, 22, 1, 21, 2121, 1111, 1, 21, 211, 11, 121, 1, 21, 2121, 1111, 11, 1121, 12, 21, 111, 1111, 11, 1121, 12, 211, 222, 21, 221, 1222, 11, 21, 221, 222, 21, 221};
char a_3;
char ch = 'A';
int s = 0,i,j=0;
do
{
for ( i = 0; i < 26; i++)
{
if (a_2 == a_0)
a_3 = ch + i;
}
for (i = 0; i < 10; i++)
{
if (a_2 == a_1)
a_3 = s + i;
}
++j;
} while ( j<=37);
for (i = 0; i<j - 1; i++)
{
printf("%c", a_3);
}
system("pause");
}
页:
[1]