Computer Hope
Software => Computer programming => Topic started 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,
#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;
}
-
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?
-
Why are you posting in old topics?
-
Because people might be hoping to get them answered, have this thread on a bookmark, like me.
You never know.
-
Well usually if there's no response within a month, we don't reply at all.
-
Maybe not you, but I will.
I don't like to assume things like the rest of the sheep.
-
Maybe not you, but I will.
Fine, be different. But the threads will just be locked.
-
Maybe not you, but I will.
I don't like to assume things like the rest of the sheep.
is that you, SpectateSwamp?
-
*censored*, no.
Look up my IP if you like.
I am Treval.
-
*censored*
mind your language please
-
mind your language please
This is a public forum with young members.
-
hoisted by their own petard.
-
hoisted by their own petard.
What?
-
Hoist with their own petard.
-
Hoist with their own petard.
petard?
-
petard?
Yes. Petard. (Or petar)
-
Helpmeh thought he meant retard.
-
Helpmeh thought he meant retard.
No. I do not know what "petard" is.
-
No. I do not know what "petard" is.
Then you should look here (http://lmgtfy.com/?q=petard)
-
Then you should look here (http://lmgtfy.com/?q=petard)
So let me get this straight.
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."
-
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
-
faire sauter, faire péter = to blow up
-
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
-
Yes, we saw it the first time.
-
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.
-
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.
-
;D
-
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. :')
-
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. :')
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
-
Did you brush your teeth, BC?
-
Did you brush your teeth, BC?
???
I was pointing out that my quote was specifically referring to the unit you mentioned.