No older revisions available
No older revisions available
소스 코드 ¶
~cpp
#include<iostream>
using namespace std;
char code[8][10];
bool test(char* a,char* b);
void main()
{
cout<<"해독가능성을 판별할 코드들을 입력하세요?!!";
char temp;
int code_number=0;
int code_byte=0;
int same=0;
cin.get(temp);
while(temp != '\n')
{
if(temp!=' ')
{
code[code_number][code_byte]=temp;
code_byte++;
}
else
{
code[code_number][code_byte]='\n';
code_number++;
code_byte=0;
}
cin.get(temp);
}
for(int i=0 ; i<=code_number-1 ; i++)
for(int j=i+1 ; j<=code_number ; j++)
{
if(test(code[i],code[j])==true)
same++;
}
if(same>0)
cout<<"Set is not immediately decodable ";
else
cout<<"Set is immediately decodable ";
cout<<endl;
}
bool test(char* a,char* b)
{
int i=0;
while(a[i]!='\n')
{
if(a[i]!=b[i])
return false;
i++;
}
return true;
}