@zitxbit
89 / 741 / 75
Регистрация: 11.04.2012
Сообщений: 971
|
02.04.2014, 15:41
|
|
C++ | 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
| #include <stdio.h>
#include <conio.h>
#include <string.h>
#include <locale.h>
#include <wchar.h>
#define N 5
int main(int argc, char** argv)
{
static char* psgn[N] = { "010001010111", "0101010111001", "1001100", "0100110", "001101111" };
static char* msg = "010101001010100111110011100101010101000001110001001101010101010101010001111101011111";
setlocale(LC_ALL,"Russian");
//=======V1=========
bool found = false;
for (int index = 0; index < N && !found; index++)
found = strstr(msg, psgn[index]) ? 1 : 0;
//=======V2=========
for (int index = 0; index < N && !found; index++)
for (int r = 0; msg[r] != '\0' && !found; r++)
{
double status = 0;
for (int q = r, t = 0; psgn[index][t] != '\0'; q++, t++)
status+=(psgn[index][t] == msg[q]) ? ((double)1 / strlen(psgn[index])) : 0;
found = (status >= 0.99) ? 1 : 0;
}
wprintf(L"%s\n", (!found) ? L"МСТ" : L"ЛТР");
_getch();
return 0;
} |
|
1
|