Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: my little project  (Read 12656 times)

0 Members and 1 Guest are viewing this topic.

airyoubreathe

    Topic Starter


    Rookie
    my little project
    « on: December 17, 2009, 06:06:10 PM »
    When I was a kid, my uncle taught me c++, in the last couple months I got interested in it again, I have read a couple online tutorials and feel comfortable with console applications now, I am now working on a rather simple project, i am trying to compare a picture of a 10 by 10 d and a 10 by 10 g, for some reason when I run it, after I enter what i want examined it says theres an error and it must shut down, its that little box where you can send an error report to microsoft, i narrowed it down to line 77 (youll see it in a minute, ill put a comment next to it) thankyou, if you need my computers info ill post it,

    Code: [Select]
    #include <iostream>
    #include <stdlib>
    #include <string>
    #include <conio.h>

    using namespace std;

    string d1[10];      // pic 1 of d
    string g1[10];      // pic 1 of g
    string in[10];      // what is entered
    float dc;           // likeliness of d
    float gc;           // likeliness of g
    float dpr;          // percentage to be d
    float gpr;          // percentage to be g
    float tpr;          // what times d/g to be 100
    int cdt;            // tests if it is already to be a part of d
    int np;             // np = n plus nm = n minus, same for x
    int nm;
    int xp;
    int xm;

    void dlib()         // defines library
    {
    d1[0] = "g@@ggggggg";
    d1[1] = "g@g@gggggg";
    d1[2] = "g@gg@ggggg";
    d1[3] = "g@ggg@gggg";
    d1[4] = "g@gggg@ggg";
    d1[5] = "g@gggg@ggg";
    d1[6] = "g@ggg@gggg";
    d1[7] = "g@gg@ggggg";
    d1[8] = "g@g@gggggg";
    d1[9] = "g@@ggggggg";
    g1[0] = "g@@@@@@@gg";
    g1[1] = "g@ggggg@gg";
    g1[2] = "g@gggggggg";
    g1[3] = "g@gggggggg";
    g1[4] = "g@gggg@@@g";
    g1[5] = "gg@gggg@gg";
    g1[6] = "ggg@ggg@gg";
    g1[7] = "gggg@@@ggg";
    g1[8] = "gggggggggg";
    g1[9] = "gggggggggg";

    }

    #define CMP if (in[np][x] == d1[np][x]) { \
    dc++;\
    cdt++;\
    }\
    else if (in[nm][x] == d1[nm][x]) {\
    dc++;\
    cdt++;\
    }\
    else if (in[n][xp] == d1[n][xp]) {\
    dc++;\
    cdt++;\
    }\
    else if (in[n][xm] == d1[n][xm]) {\
    dc++;\
    cdt++;\
    }\
    else {\
    dc++;\
    }\

    void perc()         // calculates what it is
    {
    for (int n=9; n>=0; n--) {
    for (int x=9; x>=0; x--) {
    np = n + 1;
    nm = n - 1;
    system("PAUSE"); // 1
    xp = x + 1;
    xm = x - 1;
    system("PAUSE"); // 2
    if (in[n][x] == d1[n][x]) {          // this is it!!!
    system("PAUSE"); // 3
    CMP
    }

    else if (in[n][x] == g1[n][x]) {
    if (cdt == 0) {
    if (in[n][x] == g1[n][x]) {
    gc++;
    }
    }
    }
    cdt = 0;
    system("PAUSE");  // 6
    }
    }
    tpr = 100/dc;   // caculates percentage of d and g
    dpr = 100 - (gc * tpr);
    tpr = 100/gc;
    gpr = 100 - (dc * tpr);
    }

    int main()
    {
    cdt = 0;
    dlib();
    cout << "hello, enter in what you would like to be tested, please only use '@' and 'g'" << endl;
    for (int p=0; p<10; p++) {
    cin >> in[p];
    }
    perc();
    system("PAUSE");
    cout << "likeliness to be d: " << dpr << endl << "likeliness to be g: " << gpr << endl;
    getch();
    return 0;
    }

    Treval



      Hopeful

      Thanked: 14
      Re: my little project
      « Reply #1 on: January 21, 2010, 11:42:26 AM »
      Don't know why your if line in #define at line 47 is marked green:
      http://pastebin.com/d7742d53f

      Might have to do with that it gets stuck.
      Reasons I think of:

      1) Array elements not defined
      2) One or both array elements referred to don't exist
      3) ArrayIndexes out of bounds
      4) Add a sort of break statement?

      What is CMP?



      kpac

      • Web moderator


      • Hacker

      • kpac®
      • Thanked: 184
        • Yes
        • Yes
        • Yes
      • Certifications: List
      • Computer: Specs
      • Experience: Expert
      • OS: Windows 7
      Re: my little project
      « Reply #2 on: January 21, 2010, 11:49:31 AM »
      Why are you posting in old topics?

      Treval



        Hopeful

        Thanked: 14
        Re: my little project
        « Reply #3 on: January 21, 2010, 11:55:23 AM »
        Because people might be hoping to get them answered, have this thread on a bookmark, like me.
        You never know.

        kpac

        • Web moderator


        • Hacker

        • kpac®
        • Thanked: 184
          • Yes
          • Yes
          • Yes
        • Certifications: List
        • Computer: Specs
        • Experience: Expert
        • OS: Windows 7
        Re: my little project
        « Reply #4 on: January 21, 2010, 11:58:27 AM »
        Well usually if there's no response within a month, we don't reply at all.

        Treval



          Hopeful

          Thanked: 14
          Re: my little project
          « Reply #5 on: January 21, 2010, 12:09:54 PM »
          Maybe not you, but I will.
          I don't like to assume things like the rest of the sheep.

          kpac

          • Web moderator


          • Hacker

          • kpac®
          • Thanked: 184
            • Yes
            • Yes
            • Yes
          • Certifications: List
          • Computer: Specs
          • Experience: Expert
          • OS: Windows 7
          Re: my little project
          « Reply #6 on: January 21, 2010, 12:22:56 PM »
          Quote
          Maybe not you, but I will.
          Fine, be different. But the threads will just be locked.

          BC_Programmer


            Mastermind
          • Typing is no substitute for thinking.
          • Thanked: 1140
            • Yes
            • Yes
            • BC-Programming.com
          • Certifications: List
          • Computer: Specs
          • Experience: Beginner
          • OS: Windows 11
          Re: my little project
          « Reply #7 on: January 21, 2010, 12:25:53 PM »
          Maybe not you, but I will.
          I don't like to assume things like the rest of the sheep.

          is that you, SpectateSwamp?
          I was trying to dereference Null Pointers before it was cool.

          Treval



            Hopeful

            Thanked: 14
            Re: my little project
            « Reply #8 on: January 21, 2010, 12:45:22 PM »
            *censored*, no.
            Look up my IP if you like.
            I am Treval.

            Salmon Trout

            • Guest
            Re: my little project
            « Reply #9 on: January 21, 2010, 02:32:43 PM »
            *censored*

            mind your language please

            Helpmeh



              Guru

            • Roar.
            • Thanked: 123
              • Yes
              • Yes
            • Computer: Specs
            • Experience: Familiar
            • OS: Windows 8
            Re: my little project
            « Reply #10 on: January 21, 2010, 02:44:46 PM »
            mind your language please
            This is a public forum with young members.
            Where's MagicSpeed?
            Quote from: 'matt'
            He's playing a game called IRL. Great graphics, *censored* gameplay.

            BC_Programmer


              Mastermind
            • Typing is no substitute for thinking.
            • Thanked: 1140
              • Yes
              • Yes
              • BC-Programming.com
            • Certifications: List
            • Computer: Specs
            • Experience: Beginner
            • OS: Windows 11
            Re: my little project
            « Reply #11 on: January 22, 2010, 08:56:08 AM »
            hoisted by their own petard.
            I was trying to dereference Null Pointers before it was cool.

            Helpmeh



              Guru

            • Roar.
            • Thanked: 123
              • Yes
              • Yes
            • Computer: Specs
            • Experience: Familiar
            • OS: Windows 8
            Re: my little project
            « Reply #12 on: January 22, 2010, 08:12:03 PM »
            Where's MagicSpeed?
            Quote from: 'matt'
            He's playing a game called IRL. Great graphics, *censored* gameplay.

            Salmon Trout

            • Guest
            Re: my little project
            « Reply #13 on: January 23, 2010, 02:33:22 AM »
            Hoist with their own petard.

            Helpmeh



              Guru

            • Roar.
            • Thanked: 123
              • Yes
              • Yes
            • Computer: Specs
            • Experience: Familiar
            • OS: Windows 8
            Re: my little project
            « Reply #14 on: January 23, 2010, 07:36:43 AM »
            Where's MagicSpeed?
            Quote from: 'matt'
            He's playing a game called IRL. Great graphics, *censored* gameplay.

            Salmon Trout

            • Guest
            Re: my little project
            « Reply #15 on: January 23, 2010, 07:37:59 AM »

            kpac

            • Web moderator


            • Hacker

            • kpac®
            • Thanked: 184
              • Yes
              • Yes
              • Yes
            • Certifications: List
            • Computer: Specs
            • Experience: Expert
            • OS: Windows 7
            Re: my little project
            « Reply #16 on: January 23, 2010, 07:45:16 AM »
            Helpmeh thought he meant retard.

            Helpmeh



              Guru

            • Roar.
            • Thanked: 123
              • Yes
              • Yes
            • Computer: Specs
            • Experience: Familiar
            • OS: Windows 8
            Re: my little project
            « Reply #17 on: January 23, 2010, 08:43:23 AM »
            Helpmeh thought he meant retard.
            No. I do not know what "petard" is.
            Where's MagicSpeed?
            Quote from: 'matt'
            He's playing a game called IRL. Great graphics, *censored* gameplay.

            Salmon Trout

            • Guest
            Re: my little project
            « Reply #18 on: January 23, 2010, 08:56:01 AM »
            No. I do not know what "petard" is.

            Then you should look here


            Helpmeh



              Guru

            • Roar.
            • Thanked: 123
              • Yes
              • Yes
            • Computer: Specs
            • Experience: Familiar
            • OS: Windows 8
            Re: my little project
            « Reply #19 on: January 23, 2010, 09:09:01 AM »
            Then you should look here


            So let me get this straight.
            Quote from: BC_Programmer
            hoisted by their own small bomb?

            Now that I read farther, I see "Injured by the device that you intended to use to injure others."
            Where's MagicSpeed?
            Quote from: 'matt'
            He's playing a game called IRL. Great graphics, *censored* gameplay.

            harry 48



              Egghead

            • lay back , relax and chill out
            • Thanked: 129
              • Yes
              • Yes
              • Yes
              • Dribbling Pensioner
            • Certifications: List
            • Experience: Familiar
            • OS: Windows 7
            Re: my little project
            « Reply #20 on: January 23, 2010, 02:48:10 PM »
            to break wind



            Main Entry: pe·tard
            Pronunciation: \pə-ˈtär(d)\
            Function: noun
            Etymology: Middle French, from peter to break wind, from pet expulsion of intestinal gas, from Latin peditum, from neuter of peditus, past participle of pedere to break wind; akin to Greek bdein to break wind
            Date: 1598
            1 : a case containing an explosive to break down a door or gate or breach a wall
            2 : a firework that explodes with a loud report


            Salmon Trout

            • Guest
            Re: my little project
            « Reply #21 on: January 23, 2010, 03:21:02 PM »
            faire sauter, faire péter = to blow up

            harry 48



              Egghead

            • lay back , relax and chill out
            • Thanked: 129
              • Yes
              • Yes
              • Yes
              • Dribbling Pensioner
            • Certifications: List
            • Experience: Familiar
            • OS: Windows 7
            Re: my little project
            « Reply #22 on: January 23, 2010, 03:56:23 PM »
            to break wind



            Main Entry: pe·tard
            Pronunciation: \pə-ˈtär(d)\
            Function: noun
            Etymology: Middle French, from peter to break wind, from pet expulsion of intestinal gas, from Latin peditum, from neuter of peditus, past participle of pedere to break wind; akin to Greek bdein to break windDate: 1598
            1 : a case containing an explosive to break down a door or gate or breach a wall
            2 : a firework that explodes with a loud report



            Salmon Trout

            • Guest
            Re: my little project
            « Reply #23 on: January 23, 2010, 05:12:34 PM »
            Yes, we saw it the first time.

            BC_Programmer


              Mastermind
            • Typing is no substitute for thinking.
            • Thanked: 1140
              • Yes
              • Yes
              • BC-Programming.com
            • Certifications: List
            • Computer: Specs
            • Experience: Beginner
            • OS: Windows 11
            Re: my little project
            « Reply #24 on: January 24, 2010, 07:06:41 AM »
            a petard was also for explosions... in fact, that was the original name.

            ST has already quite fitly explained the entymology and what it means.

            Additionally, it would be pretty stupid for Ensemble Studios to name a unit a "petard" if it's one and only meaning was the definition Harry posted.

            I was trying to dereference Null Pointers before it was cool.

            Helpmeh



              Guru

            • Roar.
            • Thanked: 123
              • Yes
              • Yes
            • Computer: Specs
            • Experience: Familiar
            • OS: Windows 8
            Re: my little project
            « Reply #25 on: January 24, 2010, 10:46:29 AM »
            The first definition of petard I read was a small bomb...so I put it together, "hoisted by their own small bomb." and it obviously didn't make sense, so I looked at it again and saw exactly what you wrote BC. The definition of that was in my post.
            Where's MagicSpeed?
            Quote from: 'matt'
            He's playing a game called IRL. Great graphics, *censored* gameplay.

            harry 48



              Egghead

            • lay back , relax and chill out
            • Thanked: 129
              • Yes
              • Yes
              • Yes
              • Dribbling Pensioner
            • Certifications: List
            • Experience: Familiar
            • OS: Windows 7
            Re: my little project
            « Reply #26 on: January 24, 2010, 12:18:10 PM »
             ;D

            Treval



              Hopeful

              Thanked: 14
              Re: my little project
              « Reply #27 on: January 26, 2010, 08:04:50 PM »
              Lmao.. none of you have played Age Of Empires II/III apparently..
              The petards are those annoying guys who blow up walls by blowing up themselves. :')

              BC_Programmer


                Mastermind
              • Typing is no substitute for thinking.
              • Thanked: 1140
                • Yes
                • Yes
                • BC-Programming.com
              • Certifications: List
              • Computer: Specs
              • Experience: Beginner
              • OS: Windows 11
              Re: my little project
              « Reply #28 on: January 27, 2010, 02:26:24 AM »
              Lmao.. none of you have played Age Of Empires II/III apparently..
              The petards are those annoying guys who blow up walls by blowing up themselves. :')

              Quote
              Additionally, it would be pretty stupid for Ensemble Studios to name a unit a "petard" if it's one and only meaning was the definition Harry posted.

               ;D
              I was trying to dereference Null Pointers before it was cool.

              Treval



                Hopeful

                Thanked: 14
                Re: my little project
                « Reply #29 on: January 27, 2010, 02:56:06 AM »
                Did you brush your teeth, BC?

                BC_Programmer


                  Mastermind
                • Typing is no substitute for thinking.
                • Thanked: 1140
                  • Yes
                  • Yes
                  • BC-Programming.com
                • Certifications: List
                • Computer: Specs
                • Experience: Beginner
                • OS: Windows 11
                Re: my little project
                « Reply #30 on: January 27, 2010, 03:03:02 AM »
                Did you brush your teeth, BC?

                 ???

                I was pointing out that my quote was specifically referring to the unit you mentioned.
                I was trying to dereference Null Pointers before it was cool.