matching and convert program

Go4Expert Member
1Mar2010,13:56   #1
nonie azlan's Avatar
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...
Skilled contributor
1Mar2010,20:52   #2
techgeek.in's Avatar
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..
Go4Expert Member
2Mar2010,06:34   #3
nonie azlan's Avatar
huuhuu.. i don't know how to doing.. please help me..
Skilled contributor
2Mar2010,11:02   #4
techgeek.in's Avatar
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;
}
Go4Expert Member
2Mar2010,11:16   #5
nonie azlan's Avatar
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)
Skilled contributor
2Mar2010,12:22   #6
techgeek.in's Avatar
i have run the program in turbo c++..nd it is running fine...which compiler do u use??
Go4Expert Member
2Mar2010,14:27   #7
nonie azlan's Avatar
i'm using Microsoft Visual C++ 6.0. am i run it to the correct way?
Ambitious contributor
3Mar2010,09:40   #8
seangtz's Avatar
I have experience with using Microsoft Visual........
Go4Expert Member
4Mar2010,09:43   #9
nonie azlan's Avatar
hmmm... ok... i got u... so how? can't do anything ??
Skilled contributor
4Mar2010,15:33   #10
techgeek.in's Avatar
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...