|
Your while() loops are backwards. Think about drawing this figure on paper. You start with the first column of the first row, then the second column of the first row, etc. After the last column, you go to the next row (i.e., first column of the second row).
You've not changed the inner printf() statement to use a width specifier. Did you not read the link I offered? It should look like:
printf("| %2d", number);
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
I just cannot seem to get my head wrapped around this for some reason.
here is what I changed.
{
for (int r = 0;r <= rows; r++);
{
r = r + 1;
printf (" \n");
boxnum = boxnum + 1;
r=r++;
for (int c=0; c <= cols; c++);
{
c = c + 1;
printf (" %2d|", boxnum);
boxnum = boxnum + 1;
c = c++;
}
unit_height = rows * mbxhgt;
unit_width = cols * mbxwid;
printf ("\nOverall height of mailbox unit: %d", unit_height);
printf ("\nOverall width of mailbox unit: %d\n", unit_width);
return (0);
}
}}
|
|
|
|
|
kbury wrote: for (int r = 0;r <= rows; r++);
{
r = r + 1;
...
r=r++;
How many times does r (and c ) need to be incremented? Also, that rogue semicolon is sure to cause you grief.
There's a problem with boxnum , but it does not affect the box-drawing. I'll withold the answer until you've studied it more.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
 changed code to this
<#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#define mbxhgt 6
#define mbxwid 4
int main (void)
{
int rows,
cols,
r = 1,
c = 1,
boxnum = 1,
unit_height,
unit_width;
system("cls");
printf ("Mailbox Layout Program\n\n");
printf ("How many rows of mailboxes will there be?");
scanf ("%d", &rows);
printf ("\nHow many columns of mailboxes will there be?");
scanf ("%d", &cols);
printf ("\n\nThe numbering layout will be:\n");
printf("+---+---+---+---+---+\n|");
while (c <= cols)
{c = c + 1;
printf (" %d |", boxnum);
boxnum = boxnum + 1;
}
while (r <= rows)
{r = r + 1;
printf ("\n \n");
if (boxnum <= 1);
printf("| %d | ", boxnum++);}
unit_height = rows * mbxhgt;
unit_width = cols * mbxwid;
printf ("\nOverall height of mailbox unit: %d", unit_height);
printf ("\nOverall width of mailbox unit: %d\n", unit_width);
return (0);
}/pre>
now looks like this:
How many rows of mailboxes will there be?4
How many columns of mailboxes will there be?5
The numbering layout will be:
+---+---+---+---+---+
| 1 | 2 | 3 | 4 | 5 |
| 6 |
| 7 |
| 8 |
| 9 |
Overall height of mailbox unit: 24
Overall width of mailbox unit: 20
|
|
|
|
|
You are just glutton for punishment, aren't you? As I've said, and demonstrated, you cannot have two separate loops.
kbury wrote: if (boxnum <= 1);
Other than being unnecessary, do you notice anything wrong with this? My compiler warns me with a C4390 warning.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
I guess a gluton for punishment. I am new at this and am trying to learn from a online class, which seems to make this more difficult than I had expected.
|
|
|
|
|
What's difficult about comparing your code to mine?
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
I am using the LCC Win 32 compiler and when I remove the semicolon away from if (boxnum <= 1); It does not print out the 6, 7, 8, 9 at all.
|
|
|
|
|
anyways I changed the code and now it does this. Do i need to change the if boxnum statement?
printf ("\n\nThe numbering layout will be:\n");
while (r <= rows)
{
r = r + 1;
printf ("\n \n");
while (c <= cols)
c = c + 1;
printf (" %d |", boxnum);
boxnum = boxnum + 1;
if (boxnum <= 1);
printf(" %d | ", boxnum++);
}
unit_height = rows * mbxhgt;
unit_width = cols * mbxwid;
printf ("\nOverall height of mailbox unit: %d", unit_height);
printf ("\nOverall width of mailbox unit: %d\n", unit_width);
return (0);
}
Mailbox Layout Program
How many rows of mailboxes will there be?4
How many columns of mailboxes will there be?5
The numbering layout will be:
1 | 2 |
3 | 4 |
5 | 6 |
7 | 8 |
Overall height of mailbox unit: 24
Overall width of mailbox unit: 20
|
|
|
|
|
kbury wrote: while (c <= cols)
For all but the first row, when will c ever be LE cols again? Furthermore, without braces for the inner while() loop, what statements do you expect will be executed?
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
I am trying to stick to this flowchart given to me. Maybe I just do not understand it.
In the flowchart it is only called where I have it in the code and after boxnum it is suppose to go back to col.
|
|
|
|
|
Counting this one, I've posted 8 times to this thread, which was 7 times too many. I showed you the answer in my first post. You continue to use your code, which I do not have a problem with, but you still refuse to make the necessary changes or even compare the two to see why they behave differently. I'm confused as to why a person would do this.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
Thanks for your help. I tried to code it just like you had in the 1st answer, but my compiler would not compile it.
|
|
|
|
|
kbury wrote: I tried to code it just like you had in the 1st answer...
Using copy & paste?
kbury wrote: ...but my compiler would not compile it.
It was standard C code. What error(s) did you receive?
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
plz can anyone tell me how to convert a regular exp to trasition table or dfa. i need the code in c or c++.
plz mail to me lavanya2290@gmail.com
|
|
|
|
|
First, no one is going to email you anything. This is a learning community, so any answers you get will be posted here.
Second, stop using SMS speak. If you want people here to respect your question, show some respect for them by spelling out words like plz.
|
|
|
|
|
That's not something that can just be dolled out in a few code snippets. Have you tried here?
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
Hello Friends
I m using OPENFILENAME structure.I want to keep tumbnail view whenever i open tht dialog.Do u hv any Idea?And i m using only win32 sdk.
Do u guys hv any Idea regarding IShellbrowser interface.Is tht helpful?
Pleasse suggest me some solution.
Thanks & Regards
Yogesh
|
|
|
|
|
|
This link was also dealing with MFC dear.Thx Anyway.
|
|
|
|
|
Well, you have lpfnHook , after all.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
But how we can use lpfnhook for view settings?Do u hv any other information regarding tht otherwise i hv to google it.
Thx
|
|
|
|
|
I got the lpfnhook but how do we can set view on its initdialog.
|
|
|
|
|
yogeshs wrote: I m using OPENFILENAME structure.I want to keep tumbnail view whenever i open tht dialog.
See here.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
this one is in MFC and I m using only win32 sdk
|
|
|
|