matching and convert program

Discussion in 'C++' started by nonie azlan, Mar 1, 2010.

  1. nonie azlan

    nonie azlan New Member

    Joined:
    Mar 1, 2010
    Messages:
    11
    Likes Received:
    0
    Trophy Points:
    0
    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...
     
  2. techgeek.in

    techgeek.in New Member

    Joined:
    Dec 20, 2009
    Messages:
    572
    Likes Received:
    19
    Trophy Points:
    0
    Occupation:
    EOC (exploitation of computers)..i m a Terminator.
    Location:
    Not an alien!! for sure
    Home Page:
    http://www.techgeek.in
    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..
     
  3. nonie azlan

    nonie azlan New Member

    Joined:
    Mar 1, 2010
    Messages:
    11
    Likes Received:
    0
    Trophy Points:
    0
    huuhuu.. i don't know how to doing.. please help me..:nonod:
     
  4. techgeek.in

    techgeek.in New Member

    Joined:
    Dec 20, 2009
    Messages:
    572
    Likes Received:
    19
    Trophy Points:
    0
    Occupation:
    EOC (exploitation of computers)..i m a Terminator.
    Location:
    Not an alien!! for sure
    Home Page:
    http://www.techgeek.in
    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;
    }
    
    
     
  5. nonie azlan

    nonie azlan New Member

    Joined:
    Mar 1, 2010
    Messages:
    11
    Likes Received:
    0
    Trophy Points:
    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)
     
  6. techgeek.in

    techgeek.in New Member

    Joined:
    Dec 20, 2009
    Messages:
    572
    Likes Received:
    19
    Trophy Points:
    0
    Occupation:
    EOC (exploitation of computers)..i m a Terminator.
    Location:
    Not an alien!! for sure
    Home Page:
    http://www.techgeek.in
    i have run the program in turbo c++..nd it is running fine...which compiler do u use??
     
  7. nonie azlan

    nonie azlan New Member

    Joined:
    Mar 1, 2010
    Messages:
    11
    Likes Received:
    0
    Trophy Points:
    0
    i'm using Microsoft Visual C++ 6.0. am i run it to the correct way?
     
  8. seangtz

    seangtz New Member

    Joined:
    Jun 6, 2008
    Messages:
    126
    Likes Received:
    3
    Trophy Points:
    0
    I have experience with using Microsoft Visual........:cuss:
     
  9. nonie azlan

    nonie azlan New Member

    Joined:
    Mar 1, 2010
    Messages:
    11
    Likes Received:
    0
    Trophy Points:
    0
    hmmm... ok... i got u... so how? can't do anything ?? :nonod:
     
  10. techgeek.in

    techgeek.in New Member

    Joined:
    Dec 20, 2009
    Messages:
    572
    Likes Received:
    19
    Trophy Points:
    0
    Occupation:
    EOC (exploitation of computers)..i m a Terminator.
    Location:
    Not an alien!! for sure
    Home Page:
    http://www.techgeek.in
    have some patience..i m getting back to u soon...
     
  11. nonie azlan

    nonie azlan New Member

    Joined:
    Mar 1, 2010
    Messages:
    11
    Likes Received:
    0
    Trophy Points:
    0
    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;
    }
     
    Last edited by a moderator: Mar 5, 2010
  12. techgeek.in

    techgeek.in New Member

    Joined:
    Dec 20, 2009
    Messages:
    572
    Likes Received:
    19
    Trophy Points:
    0
    Occupation:
    EOC (exploitation of computers)..i m a Terminator.
    Location:
    Not an alien!! for sure
    Home Page:
    http://www.techgeek.in
    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...
     
  13. nonie azlan

    nonie azlan New Member

    Joined:
    Mar 1, 2010
    Messages:
    11
    Likes Received:
    0
    Trophy Points:
    0
    ok.. i'll wait
     
  14. techgeek.in

    techgeek.in New Member

    Joined:
    Dec 20, 2009
    Messages:
    572
    Likes Received:
    19
    Trophy Points:
    0
    Occupation:
    EOC (exploitation of computers)..i m a Terminator.
    Location:
    Not an alien!! for sure
    Home Page:
    http://www.techgeek.in
    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;
    }
    
    
     
  15. nonie azlan

    nonie azlan New Member

    Joined:
    Mar 1, 2010
    Messages:
    11
    Likes Received:
    0
    Trophy Points:
    0
    hai.. unfortunately when i execute it become as per attachment..
    [​IMG]


    [​IMG][​IMG]
     

    Attached Files:

  16. techgeek.in

    techgeek.in New Member

    Joined:
    Dec 20, 2009
    Messages:
    572
    Likes Received:
    19
    Trophy Points:
    0
    Occupation:
    EOC (exploitation of computers)..i m a Terminator.
    Location:
    Not an alien!! for sure
    Home Page:
    http://www.techgeek.in
    sorry..i m not understanding why r u getting errors?? i have no clue..
     
  17. virxen

    virxen Active Member

    Joined:
    Nov 24, 2009
    Messages:
    387
    Likes Received:
    90
    Trophy Points:
    28
    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.
     
  18. nonie azlan

    nonie azlan New Member

    Joined:
    Mar 1, 2010
    Messages:
    11
    Likes Received:
    0
    Trophy Points:
    0
    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;
    }
     
    Last edited by a moderator: Mar 9, 2010
  19. nonie azlan

    nonie azlan New Member

    Joined:
    Mar 1, 2010
    Messages:
    11
    Likes Received:
    0
    Trophy Points:
    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?
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice