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...
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..
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; }
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)
hey.... i just do it as simple like below, but what i am suppose to insert if i want it loop after wrong input in agency code and emotion code?? Code: #include <iostream.h> int main() { char agency; int a ; cout<<"enter ur agency code:"; cin>> agency; if(agency == 'x') { cout<<"enter ur emotion code:"; cin>> a; if ( (a == 01) ) { cout << "love" << endl; } else if ( a == 02 ){ cout << "angry" << endl; } else if ( a == 03 ){ cout << "sad" << endl; } else { cout << "u have no emotion!!!" << endl; } } else if(agency == 'y') { cout<<"enter ur emotion code:"; cin>> a; if ( (a == 01) ) { cout << "angry" << endl; } else if ( a == 02 ){ cout << "sad" << endl; } else if ( a == 03 ){ cout << "love" << endl; } else { cout << "u have no emotion!!!" << endl; } } else { cout << "Error!" << endl; } return 0; }
what u did is not a program my dear...u did the complete manipulation with the statement...let me check it in other compilers nd then i m getting back to u....or u can do one thing..u get the concept from the code i gave u nd try to implement from thr...
my dear frnd this code is working fine in visual c++ and borland c++ as well..I have checked it several times.. 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; 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; }
i compiled your code in visual c++ 6.0, and it compiles and runs with no errors nonie azlan post your code here.maybe you changed or forgot something in the code.
hai.. here as per request... 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; 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; }
hai... so easy n happy to say that today i can run that program smoothly... wow! i need to work hard to understand your program.. could u help me when i need u to explain if i have any question?