Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 ACSL question
Index -> Programming, C++ -> C++ Help
Goto page Previous  1, 2
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
AsianSensation




PostPosted: Thu Jul 03, 2003 9:24 pm   Post subject: (No subject)

ok, I changed the code around(see edit), but still, it won't output anything, the cursor just flashes. UBC_Wiskatos's works, except I don't know that much about what he did, apparently, I skipped the case section of the tutorial.

so what's wrong with it now?
Sponsor
Sponsor
Sponsor
sponsor
UBC_Wiskatos




PostPosted: Thu Jul 03, 2003 10:10 pm   Post subject: (No subject)

Try this:

I don't think your original array values correspond to the shapes, I changed them in my code, but they're in their original form here. Anyway, the problem seems to be with the if seeing if the char is equal to a, b, or c. I think this should work.

I think the core problem is that you use double quotes instead of single quotes, since single quotes are for (single-character) chars.

code:

#include <iostream>
using namespace std;

int main ()
{

int tot, posx, posy;
int count = 0;
int pos [8][8];

for (int x= 0; x<8; x++)
{
   for (int y= 0; y<8; y++)
   {
      pos [x][y] = 0;
   }
}

char type;

   cout << "Input the total number: ";
   cin >> tot;

   for (int i=0;i<tot; i++)
   {
      cout << "Type of block (A, B, C): ";
      cin >> type;
      cout << "X-Coord: ";
      cin >> posx;
      cout << "Y-Coord: ";
      cin >> 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<8; k++)
{
   for (int j=0; j<8; j++)
   {
      if (pos[k][j] != 0)
      {
         count++;
      }
   }
}

  cout << count << endl;
  return 0;
}
SilverSprite




PostPosted: Thu Jul 03, 2003 10:58 pm   Post subject: (No subject)

you did that AGAIN!! i told you not to!! and so did so many other ppl asian
rizzix




PostPosted: Fri Jul 04, 2003 10:35 am   Post subject: (No subject)

lol
AsianSensation




PostPosted: Fri Jul 04, 2003 7:59 pm   Post subject: (No subject)

man.......Im so messed up it's not even funny.....
I found out the problem

code:

for (int k=0; k<8; k++)


instead, I had this:

code:

for (int k=0; k<8; i++)


man....Im soooo out of it.....

maybe the SAT stuff is detrimental to my health...
UBC_Wiskatos




PostPosted: Fri Jul 04, 2003 9:08 pm   Post subject: (No subject)

LOL, jeez man, I told you about that error a few posts back! Those SATs are going to kill you. Very Happy
Display posts from previous:   
   Index -> Programming, C++ -> C++ Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 2 of 2  [ 21 Posts ]
Goto page Previous  1, 2
Jump to:   


Style:  
Search: