|
-
Apr 2nd, 2001, 05:20 AM
#1
Thread Starter
Frenzied Member
Write the code which will print out this
1
232
34543
4567654
567898765
67890109876
7890123210987
890123454321098
90123456765432109
0123456789876543210
Last edited by Vlatko; Apr 2nd, 2001 at 05:26 AM.
-
Apr 2nd, 2001, 05:33 AM
#2
Monday Morning Lunatic
And nicely formatted as well:
Code:
#include <iostream>
using namespace std;
int MyTrunc(int iNum) {
int temp = iNum;
while(temp >= 10) temp -= 10;
return temp;
}
void DrawPyramid(int iMaxOuter) {
for(int i = 1; i <= iMaxOuter; i++) {
for(int j = i; j < iMaxOuter; j++) {
cout << " ";
}
if(i == 1) {
cout << "1";
} else {
for(j = 0; j < i; j++) {
cout << MyTrunc(i+j);
}
for(j = i-2; j >= 0; j--) {
cout << MyTrunc(i+j);
}
}
cout << endl;
}
}
void main() {
DrawPyramid(10);
}
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Apr 2nd, 2001, 12:09 PM
#3
Thread Starter
Frenzied Member
Cool parksie!
-
Apr 2nd, 2001, 12:16 PM
#4
Monday Morning Lunatic
I already had that code stashed away because I got a question for that emailed to me through AllExperts
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Apr 2nd, 2001, 12:32 PM
#5
Thread Starter
Frenzied Member
I was looking at some old C book from my uncle and saw some pyramid stuff. This seemed very interesting and so i posted it..
-
Apr 2nd, 2001, 04:08 PM
#6
Write the code which will print out this
Code:
cout << "1" << endl;
cout << "232" << endl;
cout << "34543" << endl;
cout << "4567654" << endl;
cout << "567898765" << endl;
cout << "67890109876" << endl;
cout << "7890123210987" << endl;
cout << "890123454321098" << endl;
cout << "90123456765432109" << endl;
cout << "0123456789876543210" << endl;
You didn't specify how
-
Apr 2nd, 2001, 04:12 PM
#7
Monday Morning Lunatic
You're such a cheeky git, Megatron 
Nice attitude tho
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Apr 3rd, 2001, 04:04 AM
#8
Thread Starter
Frenzied Member
cout << "1" << endl;
cout << "232" << endl;
cout << "34543" << endl;
cout << "4567654" << endl;
cout << "567898765" << endl;
cout << "67890109876" << endl;
cout << "7890123210987" << endl;
cout << "890123454321098" << endl;
cout << "90123456765432109" << endl;
cout << "0123456789876543210" << endl;
I knew somebody will post that
-
Apr 3rd, 2001, 10:33 PM
#9
Hyperactive Member
??
How does your function work, Parksie? )just dont get it
Amon Ra
The Power of Learning.
-
Apr 4th, 2001, 04:24 AM
#10
Monday Morning Lunatic
I don't know...I wrote it quite a while ago -- try stepping through it with the debugger.
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Apr 4th, 2001, 08:05 PM
#11
Hyperactive Member
ok
Amon Ra
The Power of Learning.
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
|