Computer Hope

Software => Computer programming => Topic started by: airyoubreathe on December 17, 2009, 06:06:10 PM

Title: my little project
Post by: airyoubreathe 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;
}
Title: Re: my little project
Post by: Treval 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 (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?


Title: Re: my little project
Post by: kpac on January 21, 2010, 11:49:31 AM
Why are you posting in old topics?
Title: Re: my little project
Post by: Treval 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.
Title: Re: my little project
Post by: kpac on January 21, 2010, 11:58:27 AM
Well usually if there's no response within a month, we don't reply at all.
Title: Re: my little project
Post by: Treval 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.
Title: Re: my little project
Post by: kpac 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.
Title: Re: my little project
Post by: BC_Programmer 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?
Title: Re: my little project
Post by: Treval on January 21, 2010, 12:45:22 PM
*censored*, no.
Look up my IP if you like.
I am Treval.
Title: Re: my little project
Post by: Salmon Trout on January 21, 2010, 02:32:43 PM
*censored*

mind your language please
Title: Re: my little project
Post by: Helpmeh on January 21, 2010, 02:44:46 PM
mind your language please
This is a public forum with young members.
Title: Re: my little project
Post by: BC_Programmer on January 22, 2010, 08:56:08 AM
hoisted by their own petard.
Title: Re: my little project
Post by: Helpmeh on January 22, 2010, 08:12:03 PM
hoisted by their own petard.
What?
Title: Re: my little project
Post by: Salmon Trout on January 23, 2010, 02:33:22 AM
Hoist with their own petard.
Title: Re: my little project
Post by: Helpmeh on January 23, 2010, 07:36:43 AM
Hoist with their own petard.
petard?
Title: Re: my little project
Post by: Salmon Trout on January 23, 2010, 07:37:59 AM
petard?

Yes. Petard. (Or petar)
Title: Re: my little project
Post by: kpac on January 23, 2010, 07:45:16 AM
Helpmeh thought he meant retard.
Title: Re: my little project
Post by: Helpmeh on January 23, 2010, 08:43:23 AM
Helpmeh thought he meant retard.
No. I do not know what "petard" is.
Title: Re: my little project
Post by: Salmon Trout on January 23, 2010, 08:56:01 AM
No. I do not know what "petard" is.

Then you should look here (http://lmgtfy.com/?q=petard)

Title: Re: my little project
Post by: Helpmeh on January 23, 2010, 09:09:01 AM
Then you should look here (http://lmgtfy.com/?q=petard)


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."
Title: Re: my little project
Post by: harry 48 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

Title: Re: my little project
Post by: Salmon Trout on January 23, 2010, 03:21:02 PM
faire sauter, faire péter = to blow up
Title: Re: my little project
Post by: harry 48 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


Title: Re: my little project
Post by: Salmon Trout on January 23, 2010, 05:12:34 PM
Yes, we saw it the first time.
Title: Re: my little project
Post by: BC_Programmer 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.

Title: Re: my little project
Post by: Helpmeh 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.
Title: Re: my little project
Post by: harry 48 on January 24, 2010, 12:18:10 PM
 ;D
Title: Re: my little project
Post by: Treval 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. :')
Title: Re: my little project
Post by: BC_Programmer 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
Title: Re: my little project
Post by: Treval on January 27, 2010, 02:56:06 AM
Did you brush your teeth, BC?
Title: Re: my little project
Post by: BC_Programmer 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.