matching and convert program

nonie azlan's Avatar, Join Date: Mar 2010
Go4Expert Member
hello friends..

i'm new here.. and also new in C++.
if you can help me to solve this problem, please help.....

i have to create a matching program..

situation:
agency a need to send agency b a code of expression but agency b will read different code (look table below):

agency a send to agency b

expression code expression
01 love
02 angry
03 sad

agency b receive from agency a
expression code expression
01 angry
02 sad
03 love

what should i do t make these 2 agency understand and having a correct purpose of code? show me example of program that suitable...
0
techgeek.in's Avatar, Join Date: Dec 2009
Skilled contributor
The above problem seems to be the encoding and decoding type of problem. The sender sends the expression code with the expression jumbled up with code. This problem will be easily taken care of...
From the above example it is clear that the jumbling up is done "by rotation".. IF at the receiver end the code handles the string array such that it rotates the elements to the right then the actual code expression can be obtained. Try it now, if u cnt do then ask for the code..
0
nonie azlan's Avatar, Join Date: Mar 2010
Go4Expert Member
huuhuu.. i don't know how to doing.. please help me..
0
techgeek.in's Avatar, Join Date: Dec 2009
Skilled contributor
see this:-
Code:
# include<iostream.h>
# include<conio.h>

int expr_code[]={1,2,3};
char *exp[3]={"love","angry","sad"};

int main()
{
int choice,i,count=0;
int flag=1;
char *coded[3];
int j=0;
clrscr();
while(flag)
{
cout<<"press 1 if you are organisation A\n";
cout<<"press 2 if you are organisation B\n";
cout<<"press 3 if you want to exit\n";
cin>>choice;
switch(choice)
{
case 1:
cout<<"ready to send the codes to organisation B\n";
cout<<"actual data:- \n";

while(count<3)
{
cout<<expr_code[count];
cout<<exp[count];
cout<<"\n";
count++;
}


for(i=0;i<3;i++)
{

coded[j]=new char[10];
coded[j]=exp[(i+1)%3];
++j;

}
for(i=0;i<3;i++)
{
cout<<expr_code[i]<<" "<<exp[i];
cout<<"\n";
}

cout<<"data sent:- \n";
for(i=0;i<3;i++)
{
cout<<expr_code[i]<<" "<<coded[i];
cout<<"\n";
}



break;

case 2:
cout<<"ready to receive data from organisatin A";
cout<<"data received:-  \n";
for(i=0;i<3;i++)
{
cout<<expr_code[i]<<" "<<coded[i];
cout<<"\n";
}
     j=0;
 for(i=0;i<=3;++i)
 {
 exp[j]=new char[10];
exp[j]=coded[(i+2)%3];
j++;
  }
cout<<"actual data :  \n";
for(i=0;i<3;i++)
{
cout<<expr_code[i]<<" "<<exp[i];
cout<<"\n";
}

break;
case 3:
flag=0;
break;
}
}
getch();
return 0;
}
0
nonie azlan's Avatar, Join Date: Mar 2010
Go4Expert Member
thanks a lot... but i found it like this... hmmm i can't run it...

--------------------Configuration: matching 02032010 - Win32 Debug--------------------
Build : warning : failed to (or don't know how to) build 'C:\Documents and Settings\Training.ICT-PC07-109\Local Settings\Temp\ARRAY.CPP'
Linking...
ARRAY.OBJ : error LNK2005: _main already defined in matching 02032010.obj
Debug/matching 02032010.exe : fatal error LNK1169: one or more multiply defined symbols found
Error executing link.exe.
Creating browse info file...

matching 02032010.exe - 2 error(s), 1 warning(s)
0
techgeek.in's Avatar, Join Date: Dec 2009
Skilled contributor
i have run the program in turbo c++..nd it is running fine...which compiler do u use??
0
nonie azlan's Avatar, Join Date: Mar 2010
Go4Expert Member
i'm using Microsoft Visual C++ 6.0. am i run it to the correct way?
0
seangtz's Avatar, Join Date: Jun 2008
Ambitious contributor
I have experience with using Microsoft Visual........
0
nonie azlan's Avatar, Join Date: Mar 2010
Go4Expert Member
hmmm... ok... i got u... so how? can't do anything ??
0
techgeek.in's Avatar, Join Date: Dec 2009
Skilled contributor
Quote:
Originally Posted by nonie azlan View Post
hmmm... ok... i got u... so how? can't do anything ??
have some patience..i m getting back to u soon...