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;
}