|
|
#11
|
||||
|
||||
|
Quote:
The program is supposed to count all possible squares (1x1, 2x2 etc), which are empty Yes, because so is the assignment
__________________
↑IMHO Super Flower SF-2000B case , Core i7-2600k @4.5 GHz with Thermalright True Spirit 140, ASUS P8P67 Pro Mobo, 8 GB Corsair XMS3 DDR3-1600 7-8-7-20, 2xSapphire Radeon HD 6950 2GB CF,WD Caviar Black 1TB SATA 3 HDD, Super Flower 800W 80+ gold PSU, LG BH10LS30 BD-RE, Ultron Cardreader, Windows 7 Ultimate x64, LG W2261 FullHD monitor |
|
#12
|
||||
|
||||
|
Code:
for(int d=0;(d<SQR_SIZE-i-1)&&(d<SQR_SIZE-j-1); d++) |
|
#13
|
||||
|
||||
|
Quote:
field[SQR_SIZE][SQR_SIZE]
__________________
↑IMHO Super Flower SF-2000B case , Core i7-2600k @4.5 GHz with Thermalright True Spirit 140, ASUS P8P67 Pro Mobo, 8 GB Corsair XMS3 DDR3-1600 7-8-7-20, 2xSapphire Radeon HD 6950 2GB CF,WD Caviar Black 1TB SATA 3 HDD, Super Flower 800W 80+ gold PSU, LG BH10LS30 BD-RE, Ultron Cardreader, Windows 7 Ultimate x64, LG W2261 FullHD monitor |
|
#14
|
||||
|
||||
|
Yes and you use the "lower" operator in the for loop condition statement, so you need d to be lower than SQR_SIZE, to reach index SQR_SIZE - 1 which is the highest of the field, since we start counting at 0. Alternatively you could use "lower or equal" and keep the "-1".
For an empty checkboard of SQR_SIZE = 8, in the higher left corner, where (i,j) = (0,0) your algorithm should count 8 empty squares, so d should be allowed to go from 0 to 7 and it can't be 7 now since the for loop gets terminated. |
|
#15
|
||||
|
||||
|
Ok I reverse my previous statement. You ARE right
![]() It works at last! yahoo!
__________________
↑IMHO Super Flower SF-2000B case , Core i7-2600k @4.5 GHz with Thermalright True Spirit 140, ASUS P8P67 Pro Mobo, 8 GB Corsair XMS3 DDR3-1600 7-8-7-20, 2xSapphire Radeon HD 6950 2GB CF,WD Caviar Black 1TB SATA 3 HDD, Super Flower 800W 80+ gold PSU, LG BH10LS30 BD-RE, Ultron Cardreader, Windows 7 Ultimate x64, LG W2261 FullHD monitor |
|
#16
|
||||
|
||||
|
Quote:
I do remember school assignments being fairly stupid and ambiguous.. So much posting tired.
__________________
Mmm, bacon balls. Last edited by Rottis; 04-26-2012 at 12:33 AM. |
|
#17
|
|||
|
|||
|
To hijack a bit with a C problem.
Relevant part of code is: printf("%f\n", 0.5); if (bla[1] > 0) { printf("%f\n", 0.5); } printf("%f\n", bla[1]); First 2 lines work just fine, while for the third one bla[1] is written, but Valgrind throws a long list of errors (ca 50). How come the problems appear only then, why not in the second one as well? |
|
#18
|
||||
|
||||
|
Let's say given:
class My_class //which consists of: { private: Subclass1 a; Subclass2 b; float f; public: My_class(Subclass1, Subclass2, float);//CTOR prototype ~My_class(); //DTOR //methods }; Question: What the CTOR definition should look like, so the subclasses could be initialized concurrently with My_class? i. e. My_class(Subclass1('u', 8), Subclass2("ab", 98465), 3.5)
__________________
↑IMHO Super Flower SF-2000B case , Core i7-2600k @4.5 GHz with Thermalright True Spirit 140, ASUS P8P67 Pro Mobo, 8 GB Corsair XMS3 DDR3-1600 7-8-7-20, 2xSapphire Radeon HD 6950 2GB CF,WD Caviar Black 1TB SATA 3 HDD, Super Flower 800W 80+ gold PSU, LG BH10LS30 BD-RE, Ultron Cardreader, Windows 7 Ultimate x64, LG W2261 FullHD monitor |
|
#19
|
||||
|
||||
|
what is the difference between template function and function template?
__________________
↑IMHO Super Flower SF-2000B case , Core i7-2600k @4.5 GHz with Thermalright True Spirit 140, ASUS P8P67 Pro Mobo, 8 GB Corsair XMS3 DDR3-1600 7-8-7-20, 2xSapphire Radeon HD 6950 2GB CF,WD Caviar Black 1TB SATA 3 HDD, Super Flower 800W 80+ gold PSU, LG BH10LS30 BD-RE, Ultron Cardreader, Windows 7 Ultimate x64, LG W2261 FullHD monitor |
![]() |
| Thread Tools | |
| Display Modes | |
|
|