|
-
February 26th, 2010, 09:52 PM
#1
Beginner C# hw help!!
can someone please help me with my hw?
im currently taking a beginners C# course and need some pointers on the hw. I have a very hard nosed instructor that refuses to give much help..
the objective is to get a "mountain of alphabet" given the inputs and he wants us to get the following output:
a
b c
d e f
g h i j
k l m n o
p q r s
t u v
w x
y
Inputs:
Enter a letter between 'a' and 'z':
Enter a positive integer:
Here's what i have so far:
{
char sc = Convert.ToChar(TbxLetter.Text.Trim()[0]);
int n = Convert.ToInt32(TbxInteger.Text);
if (sc < 'a' || sc > 'z')
{
TbxOutput.Text = "Please enter a letter from 'a' to 'z'!!";
return;
}
TbxOutput.Text = "";
int row = 1, col = 1;
for (int i = 1; i <= n; i++)
{
TbxOutput.Text += sc.ToString() + " ";
sc++;
if (sc > 'z') sc = 'a';
if (row == 10) row = 1;
if (col == row)
{
TbxOutput.Text += "\n";
row++;
col = 0;
}
col++;
Here's the Ouput that i get:
a
b c
d e f
g h i j
k l m n o
p q r s
t u v w x
y z a b
what do i need to do to make it continually decrease until it gets to Y and then make it start over again at Z?
any pointers would be helpful
Thanks in advance.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|