Thread: suggestion required

  1. #1
    Registered User
    Join Date
    Dec 2010
    Posts
    13

    suggestion required

    I have been trying to write and compile a program that would give a n output if any string feep is entered. 24 7
    15
    0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
    0 3 3 3 3 0 0 7 7 7 7 0 0 11 11 11 11 0 0 15 15 15 15 0
    0 3 0 0 0 0 0 7 0 0 0 0 0 11 0 0 0 0 0 15 0 0 15 0
    0 3 3 3 3 0 0 7 7 7 7 0 0 11 11 11 11 0 0 15 15 15 15 0
    0 3 0 0 0 0 0 7 0 0 0 0 0 11 0 0 0 0 0 15 0 0 0 0
    0 3 0 0 0 0 0 7 7 7 7 0 0 11 11 11 11 0 0 15 0 0 0 0
    0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
    24x7
    15
    In code blocks
    it seems as if it is not entering the loop at all. In Turbo c++, it
    executes the comment inside the loop(if you make it a code it prints
    a matrix of 6x7 of zeros)then the value of l (=toupp.....) goes 0 and
    it prints the default statement.
    Code:
    #include <iostream>
    #include <windows.h>
    #include<ctype.h>
    #include<stdio.h>
    #include <conio.h>
    #include <process.h>
    using namespace std;
    
    void gotoxy(int x, int y)
    {
            COORD coord;
            coord.X = x;
            coord.Y = y;
            SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), coord);
    
    }
    
    int main()
    {
                    int a,l,i,j,c=-1,w[6][7],q=0;
                    char g[10];
                    cout<<"Enter word:";
                    gets(g);
                    cout<<"\n\n\n\n\n\n";
                    for(a=0;g[a]!='\0';a++)
                    {
                                    for(i=0;i<7;i++)
                                     for(j=0;j<6;j++)
                                            w[i][j]=0;
                                    /*for(i=0;i<7;i++)
                                    {
                                        cout<<"\n";
                        for(j=0;j<6;j++)
                                            cout<<w[i][j];
                                    }*/
                                    l=toupper(g[a]);
                                    cout<<endl<<l;
                                    c=c+4;
                                    switch(l)
                                    {
                                                    case 65:for(i=2;i<6;i++)
                                                                             {
                                                                                            w[i][1]=c;
                                                                                            w[i][4]=c;
                                                                             }
                                                                                    for(j=2;j<4;j++)
                                                                                    {
                                                                                            w[1][j]=c;
                                                                                            w[3][j]=c;
                                                                                    }
                                                                                    break;
    
                                                    case 66:for(i=1;i<6;i++)
                                                                                            w[i][1]=c;
                                                                             for(i=2;i<5;i++)
                                                                                            w[i][4]=c;
                                                                                    for(j=2;j<4;j++)
                                                                                    {
                                                                                            w[1][j]=c;
                                                                                            w[5][j]=c;
                                                                                    }
                                                                                    for(j=2;j<5;j++)
                                                                                            w[3][j]=c;
                                                                                    break;
                                                    case 67:for(i=1;i<6;i++)
                                                                                            w[i][1]=c;
                                                                                    for(j=1;j<5;j++)
                                                                                    {
                                                                                             w[5][j]=c;
                                                                                             w[1][j]=c;
                                                                                    }
                                                                                    break;
                                                    case 68:for(i=1;i<6;i++)
                                                                                            w[i][1]=c;
                                                                             for(i=2;i<5;i++)
                                                                                            w[i][4]=c;
                                                                                    for(j=2;j<4;j++)
                                                                                    {
                                                                                            w[1][j]=c;
                                                                                            w[5][j]=c;
                                                                                    }
                                                                                    break;
                                                    case 69:for(i=1;i<6;i++)
                                                                                            w[i][1]=c;
                                                                                    for(j=1;j<5;j++)
                                                                                    {
                                                                                             w[5][j]=c;
                                                                                             w[1][j]=c;
                                                                                             w[3][j]=c;
                                                                                    }
                                                                                    break;
                                                    case 70:for(i=1;i<6;i++)
                                                                                            w[i][1]=c;
                                                                                    for(j=1;j<5;j++)
                                                                                    {
                                                                                             w[1][j]=c;
                                                                                             w[3][j]=c;
                                                                                    }
                                                                                    break;
                                                    case 71:for(i=1;i<6;i++)
                                                                                            w[i][1]=c;
                                                                                    for(j=1;j<5;j++)
                                                                                    {
                                                                                             w[5][j]=c;
                                                                                             w[1][j]=c;
                                                                                             w[3][j]=c;
                                                                                    }
                                                                                    w[4][4]=c;
                                                                                    break;
                                                    case 72:for(i=1;i<6;i++)
                                                                             {
                                                                                            w[i][1]=c;
                                                                                            w[i][4]=c;
                                                                             }
                                                                                    for(j=2;j<4;j++)
                                                                                            w[3][j]=c;
                                                                                    break;
                                                    case 73:for(i=2;i<6;i++)
                                                                                            w[i][3]=c;
                                                                                    for(j=2;j<5;j++)
                                                                                    {
                                                                                            w[1][j]=c;
                                                                                            w[5][j]=c;
                                                                                    }
                                                                                    break;
                                                    case 74:for(i=2;i<6;i++)
                                                                                            w[i][3]=c;
                                                                                    for(j=1;j<5;j++)
                                                                                            w[1][j]=c;
                                                                                    w[5][1]=w[5][2]=c;
                                                                                    break;
                                                    case 75:for(i=1;i<6;i++)
                                                                                            w[i][1]=c;
                                                                                    w[1][4]=w[2][3]=w[3][2]=w[4][3]=w[5][4]=c;
                                                                                    break;
                                                    case 76:for(i=1;i<6;i++)
                                                                                            w[i][1]=c;
                                                                                    for(j=1;j<5;j++)
                                                                                             w[5][j]=c;
                                                                                    break;
                                                    case 77:for(i=1;i<6;i++)
                                                                             {
                                                                                            w[i][1]=c;
                                                                                            w[i][4]=c;
                                                                             }
                                                                                    for(j=2;j<4;j++)
                                                                                            w[2][j]=c;
                                                                                    break;
                                                    case 78:for(i=1;i<6;i++)
                                                                             {
                                                                                            w[i][1]=c;
                                                                                            w[i][4]=c;
                                                                             }
                                                                             w[2][2]=w[3][3]=c;
                                                                             break;
                                                    case 79:for(i=1;i<6;i++)
                                                                             {
                                                                                            w[i][1]=c;
                                                                                            w[i][4]=c;
                                                                             }
                                                                                    for(j=2;j<4;j++)
                                                                                    {
                                                                                            w[1][j]=c;
                                                                                            w[5][j]=c;
                                                                                    }
                                                                                    break;
                                                    case 80:for(i=1;i<6;i++)
                                                                                            w[i][1]=c;
                                                                                    for(j=1;j<5;j++)
                                                                                    {
                                                                                             w[1][j]=c;
                                                                                             w[3][j]=c;
                                                                                    }
                                                                                    w[2][4]=c;
                                                                                    break;
                                                    case 81:for(i=1;i<6;i++)
                                                                             {
                                                                                            w[i][1]=c;
                                                                                            w[i][3]=c;
                                                                             }
                                                                                    for(j=2;j<4;j++)
                                                                                    {
                                                                                            w[1][j]=c;
                                                                                            w[5][j]=c;
                                                                                    }
                                                                                    w[5][4]=c;
                                                                                    break;
                                                    case 82:for(i=1;i<6;i++)
                                                                                            w[i][1]=c;
                                                                                    for(j=1;j<5;j++)
                                                                                    {
                                                                                             w[1][j]=c;
                                                                                             w[3][j]=c;
                                                                                    }
                                                                                    w[2][4]=w[4][3]=w[5][4]=c;
                                                                                    break;
                                                    case 83:for(j=1;j<5;j++)
                                                                                    {
                                                                                             w[5][j]=c;
                                                                                             w[1][j]=c;
                                                                                             w[3][j]=c;
                                                                                    }
                                                                                    w[2][1]=w[4][4]=c;
                                                                                    break;
                                                    case 84:for(i=1;i<6;i++)
                                                                                            w[i][3]=c;
                                                                                    for(j=1;j<6;j++)
                                                                                             w[1][j]=c;
                                                                                    break;
                                                    case 85:for(i=1;i<6;i++)
                                                                             {
                                                                                            w[i][1]=c;
                                                                                            w[i][4]=c;
                                                                             }
                                                                                    for(j=2;j<4;j++)
                                                                                            w[5][j]=c;
                                                                                    break;
                                                    case 86:for(i=1;i<4;i++)
                                                                             {
                                                                                            w[i][1]=c;
                                                                                            w[i][5]=c;
                                                                             }
                                                                             w[4][4]=w[5][3]=w[4][2]=c;
                                                                             break;
                                                    case 87:for(i=1;i<5;i++)
                                                                             {
                                                                                            w[i][1]=c;
                                                                                            w[i][5]=c;
                                                                             }
                                                                             for(j=2;j<4;j++)
                                                                                            w[5][j]=c;
                                                                             w[4][3]=w[3][3]=c;
                                                                             break;
                                                    case 88:w[1][1]=w[2][2]=w[3][3]=w[4][4]=w[5][5]=w[5][1]=w[4]
    [2]=w[2][4]=w[1][5]=c;
                                                                                    break;
                                                    case 89:for(i=3;i<6;i++)
                                                                                            w[i][3]=c;
                                                                                    w[1][1]=w[2][2]=w[2][4]=w[1][5]=c;
                                                                                    break;
                                                    case 90:for(j=1;j<5;j++)
                                                                                    {
                                                                                             w[5][j]=c;
                                                                                             w[1][j]=c;
                                                                                    }
                                                                                    w[2][3]=w[3][2]=w[4][1]=c;
                                                                                    break;
                                                    default:cout<<"Wrong Symbol";
                                                                                    getch();
                                                                                    exit(0);
                                    }
                                    for(int b=0;b<7;b++)
                                    {
                                        cout<<"\n";
                                                    //gotoxy(9+6*q,b+1);
                                                    for(int d=0;d<6;d++)
                                                    {
    
                                                                    cout<<w[b][d];
                                                    }
                                    }
                                    q++;
                    }
                    cout<<"\n"<<c;
                    cout<<"\n7x"<<q*6;
                    return 0;
    
    }
    Can anyone suggest something............................
    Please give a solution for c::b as I dont have a Turbo c++in my pc.

  2. #2
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    I used the code above, typed "feep" as suggested, and got as output:
    Code:
    70
    000000
    044440
    040000
    044440
    040000
    040000
    000004
    69
    000000
    044440
    040000
    044440
    040000
    044440
    000004
    69
    000000
    044440
    040000
    044440
    040000
    044440
    000004
    80
    000000
    044440
    040040
    044440
    040000
    040000
    000004
    4
    7x24
    if that's not what you want you'll have to explain what you do want instead.

  3. #3
    Registered User
    Join Date
    Dec 2010
    Posts
    13
    yeah..... Iwant some what the same thing that u r getting but I am not getting those output at all when I run it in code::blocks in my pC.????

  4. #4
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    Ctrl-F9 to compile, Ctrl-F10 to run. Make sure your project is in somewhere non-stupid (somewhere under My Documents would be a good start).

  5. #5
    Registered User
    Join Date
    Dec 2010
    Posts
    13
    hey and the c variable should be incremented by 4 in each outer loop and appear in each letter like starting from -1, it should be 3 in f, 7in e, 11 in e and 15 in p INSTEAD OF 4 in all of them. And that 4 in the corner of each letter grid should be 0 instead. However I want the output exactly like this

    0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
    0 3 3 3 3 0 0 7 7 7 7 0 0 11 11 11 11 0 0 15 15 15 15 0
    0 3 0 0 0 0 0 7 0 0 0 0 0 11 0 0 0 0 0 15 0 0 15 0
    0 3 3 3 3 0 0 7 7 7 7 0 0 11 11 11 11 0 0 15 15 15 15 0
    0 3 0 0 0 0 0 7 0 0 0 0 0 11 0 0 0 0 0 15 0 0 0 0
    0 3 0 0 0 0 0 7 7 7 7 0 0 11 11 11 11 0 0 15 0 0 0 0
    0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
    24x7
    15

    cancel that cout<<l; after the toupper statement................

  6. #6
    Registered User
    Join Date
    Dec 2010
    Posts
    13
    tried.... no use.

  7. #7
    Registered User
    Join Date
    Dec 2010
    Posts
    13
    Really Need help.....

  8. #8
    Registered User
    Join Date
    Dec 2007
    Posts
    2,675
    So let me get this straight...you're looking for someone to port your old Turbo C++ code (although if you wrote it, then you must have Turbo C++ -- ugh -- right?) that uses Borland's conio library to a standard C++ implementation?

  9. #9
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    Quote Originally Posted by rags_to_riches View Post
    So let me get this straight...you're looking for someone to port your old Turbo C++ code (although if you wrote it, then you must have Turbo C++ -- ugh -- right?) that uses Borland's conio library to a standard C++ implementation?
    Last I checked, the OP wanted someone to scroll the window up for him/her so that he/she could see the whole output instead of just the last 20-odd lines. I don't know whether we got any farther than that.

  10. #10
    Registered User
    Join Date
    Dec 2007
    Posts
    2,675
    Oh, I see. I reflexively see conio.h and recoil in horror.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Problem building Quake source
    By Silvercord in forum Game Programming
    Replies: 16
    Last Post: 07-11-2010, 09:13 AM
  2. Replies: 28
    Last Post: 07-16-2006, 11:35 PM
  3. NAQ: Everything you never wanted to know about CPP
    By evildave in forum C Programming
    Replies: 21
    Last Post: 12-12-2005, 10:56 AM
  4. Determining required flops to run C code
    By mollyann in forum C Programming
    Replies: 5
    Last Post: 03-30-2005, 01:28 PM