Hello~! ...again..
I got some help from you guys a while ago with this same app because it wouldn't run on winxp. It runs fine now, but my brother is still telling me he cant get it to work right...so rather than go through all the trouble of trouble shooting(he lives 7 hours away) I figured I would just translate the thing to java.
I think that even if I make an applet, he will still have to have his java all fully updated and whatnot so to avoid even that trouble, I would like to make this is simple Java Script if possible.
I just wanted to ask you guys if it was practically doable to translate this app to Java Script, or a Java applet if need be, before I dive in and start learning the details of how to put this thing together. The C++ version inputs and outputs to text files, but I figured that I would just use a text BOX instead, and have it clear the box and put the new results in the same box.
anywho, here is the C++ code:
#include "stdafx.h"
#include <fstream>
#include <iostream>
using namespace std;
struct PAIR
{
UINT num1, num2;
UINT lastdrawn;
};
int _tmain(int argc, _TCHAR* argv[])
{
UINT R[20];
UINT pair_matrix[71][71];
UINT day = 1;
PAIR pairs[4900];
ofstream fout;
ifstream fin;
cout << "Initializing.....";
memset(&pair_matrix[0], 0, 71*71*sizeof(UINT));
memset(&pairs, 0, 4900*sizeof(PAIR));
cout << "Done" << endl;
cout << "Opening results.txt.....";
fin.open("results.txt");
if(!fin.is_open())
{
cout << "Could not open results.txt. Exiting program..." << endl;
system("pause");
return 0;
}
cout << "Success" << endl;
cout << "Scanning numbers.....";
while (!fin.eof())
{
fin >> R[0];
if(R[0] == 0) continue;
fin >> R[1] >> R[2] >> R[3] >> R[4] >> R[5] >> R[6] >> R[7] >> R[8] >> R[9] >> R[10]
>> R[11] >> R[12] >> R[13] >> R[14] >> R[15] >> R[16] >> R[17] >> R[18] >> R[19];
for(int x = 0; x < 19; x++)
for(int y = x+1; y < 20; y++)
if(pair_matrix[R[x]][R[y]] == 0)
pair_matrix[R[x]][R[y]] = day;
day++;
}
cout << "Finished" << endl;
cout << "Building pair list.....";
fout.open("pairs.txt");
for(int x = 1; x <= 69; x++)
{
for(int y = x+1; y <= 70; y++)
{
for(int p = 0; p < 4900; p++)
{
if(pair_matrix[x][y] > pairs[p].lastdrawn)
{
for(int b = 4900-1; b > p; b--)
{
pairs[b] = pairs[b-1];
}
pairs[p].lastdrawn = pair_matrix[x][y];
pairs[p].num1 = x;
pairs[p].num2 = y;
break;
}
}
}
}
fout << " |last drawn| |pair|" << endl;
for(int p = 4899; p >= 0; p--)
{
if(pairs[p].num1 != 0)
{
fout << " " << pairs[p].lastdrawn << " (" << pairs[p].num1 << ", " << pairs[p].num2 << ")" << endl;
}
}
fout.close();
fin.close();
cout << "Finished." << endl << "Statistics were saved in pairs.txt" << endl;
system("pause");
return 1;
}
Thank again for any *pointers=)