
-----------------------------------
AsianSensation
Sun Jun 22, 2003 9:32 pm

ACSL question
-----------------------------------
I am doing some old ACSL question, actually, this one to be exact:

http://www.acsl.org/acsl/96-97/pdf/jr/prog2.pdf

anyways, I did the question in C++, but I dont know why it doesn't work, I did it in turing, and it worked, and I don't know what's wrong with it. could someone please help me?

btw, the question required input from file, but since i don't know how to do that, i made it keyboard input.

#include 

int main ()
{

int tot, posx, posy;
int count =0;
int pos [8][8];

for (int x= 0; x> posx >> posy;
		if (type == "a")
		{
			pos [posx-1][posy-1]++;
			pos [posx-1][posy-2]++;
			pos [posx-1][posy-3]++;
			pos [posx][posy-3]++;
			pos [posx+1][posy-3]++;

		}
		else if (type == "b")
		{
			pos [posx-1][posy-1]++;
			pos [posx][posy-1]++;
			pos [posx-1][posy-2]++;
			pos [posx][posy-2]++;
			pos [posx-1][posy-3]++;
		}
		else if (type == "c")
		{
			pos [posx-1][posy-1]++;
			pos [posx-1][posy]++;
			pos [posx-2][posy-1]++;
			pos [posx-3][posy-1]++;
			pos [posx-4][posy-1]++;
		}
	}

for (int k=0; k> type;
if (type == 'a')


that worked, but still, the program isnt working, i'll go and try and fix it, and maybe learn string while im at it.

-----------------------------------
Homer_simpson
Mon Jun 23, 2003 9:25 pm


-----------------------------------
well yeah you could check it like this i guess
if ((type[1]=='a')&&(type[2]=='\0')) then yay!!
but strings are much much easier...

-----------------------------------
rizzix
Tue Jun 24, 2003 1:48 pm


-----------------------------------

char* this_is_a_c_type_string = "this is a string";


u see c++ is backward compatible with c so that works.

yes, use pointers to char instead.

so all u have to do for checking:


if (str == "a")
    ...
else
    ...


-----------------------------------
SilverSprite
Tue Jun 24, 2003 7:43 pm


-----------------------------------
That's what i meant by strings and chars Asian.. double quotes for strings and single quotes for chars.. a char is only one character hence char(acter) and a string is for multiple characters hence a 'string' of characters..tut tut turing corruption..

-----------------------------------
AsianSensation
Wed Jul 02, 2003 9:55 pm


-----------------------------------
ok, then can someone give me a tutorial, or a site on how to use strings?

-----------------------------------
UBC_Wiskatos
Wed Jul 02, 2003 10:26 pm

Re: ACSL question
-----------------------------------
I am doing some old ACSL question, actually, this one to be exact:

http://www.acsl.org/acsl/96-97/pdf/jr/prog2.pdf

anyways, I did the question in C++, but I dont know why it doesn't work, I did it in turing, and it worked, and I don't know what's wrong with it. could someone please help me?

btw, the question required input from file, but since i don't know how to do that, i made it keyboard input.

#include 

int main ()
{

int tot, posx, posy;
int count =0;
int pos [8][8];

for (int x= 0; x> posx >> posy;
		if (type == "a")
		{
			pos [posx-1][posy-1]++1;
			pos [posx-1][posy-2]++1;
			pos [posx-1][posy-3]++1;
			pos [posx][posy-3]++1;
			pos [posx+1][posy-3]++1;

		}
		else if (type == "b")
		{
			pos [posx-1][posy-1]++1;
			pos [posx][posy-1]++1;
			pos [posx-1][posy-2]++1;
			pos [posx][posy-2]++1;
			pos [posx-1][posy-3]++1;
		}
		else if (type == "c")
		{
			pos [posx-1][posy-1]++1;
			pos [posx-1][posy]++1;
			pos [posx-2][posy-1]++1;
			pos [posx-3][posy-1]++1;
			pos [posx-4][posy-1]++1;
		}
	}

for (int k=0; i