Why in the printout of the following code s, t, and u only go up
to 9 but w and x 10? I would think they would at least go up to
the same number, be it 9 or 10.
The last line of the printout is:
column 9 row 9 u 9 v 0 w 10 x 10 y 1 z 48652
-----------------------------------------
for(s = 0; s < 9; s++)
for(t = 0; t < 9; t++)
for(u = 0; u < 9; u++)
{
if(v = Cell[s][t].GetElement(u) != 0)
for(w = 0; w < 9; w++)
{
if(w != t)
{
for(x = 0; x < 9; x++)
{
if(y = Cell[s][w].GetElement(x) != 0)
if(v >= y)
if( v == y)
{
z++;
}
}
}
}
cout << "column " << s+1 << " row " << t+1 << \\
" u " << u+1 << " v " << v << " w " << w+1 << " x " << x+1 \\
<< " y " << y << " z " << z << '\n';
} 7 2603
"John Smith" <js****@company .com> wrote in message
news:VE******** **********@twis ter.southeast.r r.com Why in the printout of the following code s, t, and u only go up to 9 but w and x 10? I would think they would at least go up to the same number, be it 9 or 10.
Incrementation takes place after the body of the for() loop is executed. In
your case, the printout occurs after the body of the w and x for loops but
inside the body of the s, t and u loops. That explains the difference.
--
John Carson
The basic "unrolled" (missused, i know) form of a for-loop is:
for( statement; conditional; operation )
{
body;
}
becomes
statement;
while( conditional )
{
body;
operation;
}
and can, in fact, replace all while-loops (but for clarity, while-loops
are still viable)
and you should see any 10s if the condition is "x<9".
The reason is simple - when outputting he sometime print out x+1 and
sometie just 'v'...
None of the variables reaches 10....
Actualy, none of the variables reaches 9, because conditions in all
cases are "x<9", when variable reaches 9 - loop body isn't executed
anymore. gu*****@gmail.c om raše: and you should see any 10s if the condition is "x<9". The reason is simple - when outputting he sometime print out x+1 and sometie just 'v'... None of the variables reaches 10....
you are wrong.
see that when the condition of the loop is evaluated (x<9) and the body
than skipped, x is already 9! otherwise the body of the loop will be
executed.
when you have something like this:
for (int i=0; i<9; i++) {
/// bla.... some statements
}
cout << i;
the output will always (if the loop was not ended abruptly) be '9'.
I'm sorry, I think I misunderstood you.
I guess you meant '9' is never PRINTED - but you wrote "none of the
variables reaches 9".
But also this is not accurate, because w does reaches 9 in before the
cout command is reached. gu*****@gmail.c om wrote: you are wrong. see that when the condition of the loop is evaluated (x<9) and the body than skipped, x is already 9! otherwise the body of the loop will be executed.
when you have something like this: for (int i=0; i<9; i++) { /// bla.... some statements } cout << i; the output will always (if the loop was not ended abruptly) be '9'.
Please quote the messages in your replies. Use the 'Reply' in the 'More
options' link if you are using the google-groups interface.
And, in
for(int i.....) { }
the scope of 'i' is restricted to within the for loop, it is not visible
outside. :-)
Cheers,
Vimal.
--
"If you would be a real seeker after truth, it is necessary that at
least once in your life you doubt, as far as possible, all things."
-- Rene Descartes This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Daniele Varrazzo |
last post by:
If you need a container to look into, there is the sets module that provides
a couple of them.
If you need a sorted list, there is the bisect module. But i don't think it
fits your need for a quick lookup: it's a python module so probably it's
slower. Furthermore you can __hash__ almost everything, but you can __cmp__
in a consistent way much less stuff.
Take definitely a look at sets.
|
by: Philip Herlihy |
last post by:
I'm creating a common navigation bar of text "buttons" using CSS. On each
page, I want the corresponding button to be "inert" (no hover, etc) as a
visual clue to where you are.
I thought I'd include simple <p> tags, and style them the same way as the
<a> tags, but I can't get it to work - I get different margins in each case.
I've reduced the situation to the essentials here:
http://philipherlihy.members.beeb.net/CssMargins/
|
by: Gérard Talbot |
last post by:
Hello all,
I'd like to know and understand the difference between, say,
<img src="/ImageFilename.png" width="123" height="456" alt="">
and
<img src="/ImageFilename.png" style="width: 123px; height: 456px;"
alt="">
|
by: simon_s_li |
last post by:
Hi,
Does anyone know if there is an event that gets fired off when I select
text in a cell of a table in HTML????
I know theres a onselect event but that does not work.
I need this so I can run a JavaScript function.
Regards
|
by: Michael Brown |
last post by:
I would like to know if .NET has some sort of event that
I can write a method for or something similar for when an
application of my choosing starts.
| |
by: I appreciate your help.... anony |
last post by:
Hi,
does anyone know whether it is possible to have a holding page
for when an application domain dies and give the "503" error, we would
like to replace that error a holding page. Can some one point me in
the direction of the solution please.
Many thanks,
phil
|
by: **Developer** |
last post by:
Anyone know a good reference for when Events occur?
I'm thinking of Load, HandleCreated, Enter, Resize(first time), Print(first
time),...
and I don't know what else might be run on control (or Form) startup
Thanks
|
by: year1943 |
last post by:
For
template <typename Tclass My ;
I can define partial spec-ns somewhat like
template <typename Tclass My<T*; or
template <typename Tclass My<Another<T ;
And full spec-n, say
template <class My<int;
What if I have a template class
template <typename T, typename Uclass My ;
|
by: db2dbdba |
last post by:
Hi All,
How can I check for when a db2stop command is last issued?
Or when a db2 force applications all command is last issued?
Thanks in advance
R
|
by: Shahid |
last post by:
Hi,
I am parsing an .HTML file that contains following example code:
<div>
<p class="html_preformatted" awml:style="HTML Preformatted"
dir="ltr" style="text-align:left"><span style="font-size:12pt;font-
family:'Arial'" xml:lang="en-US" lang="en-US">Normal Text Arial 12
Black before bullets.</span></p>
<ul>
<li class="html_preformatted" dir="ltr" style="text-
align:left"> <span style="font-size:12pt;font-family:'Arial'"
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |