![]() |
|
#1
|
|||
|
hi all, i am having some trouble learning c. its for this class i am taking outside of school, and i want to do well. what i am having trouble with is figuring out how the syntax works.
is there anyone willing to help me learn some rudimentary principles? here is a link to the problem set. i am having trouble with the mario problem. can someone please explain how to put the blank spaces in, and also how to make new lines?
__________________
![]() | ||
|
|
|||
|
#2
|
|||
|
Read about whitespace and escape sequences in C =P
__________________
Jack <Yael Graduates> - Server First Erudite
Bush <Toxic> Jeremy <TMO> - Patron Saint of Blue | ||
|
|
|||
|
#3
|
|||
|
__________________
Baalzy - 57 Gnocro, Baalz - 36 Ikscro, Adra - 51 Hileric, Fatbag Ofcrap - 25 halfuid Red99 Baalz Less - Humger, Baalzy - Ikscro If MMORPG players were around when God said, "Let there be light" they'd have called the light gay, and plunged the universe back into darkness by squatting their nutsacks over it. Picture courtesy of azeth | ||
|
|
|||
|
#4
|
|||
|
Learn C#, download eqbrowser source, pras.
Learn C++, download Eqemu source, pras | ||
|
|
|||
|
#5
|
|||
|
If I recall, it's something like cout << " ##";
The ASCI for a space is 32 (decimal) I think. Or is that c++? I started with c or c++ in school, I forget. I used Turbo C++. As far as the code is concerned, it looks simple to me. Each row above the bottom has (0+row) spaces. It looks like hte platform at the top is 2 characters in length. The width of the total pyramid can be estimated by (height+1). The number of blocks per row can be estimated by (width of the pyramid-spaces). EDIT: I forgot about the role of printf in C. You will probably want to loop printf(" "); to insert spaces on the line. Insert pound signs the same way by looping printf("#"); and ending with printf("\n"); Honestly you just need to experiment with it.
__________________
Full-Time noob. Wipes your windows, joins your groups.
Raiding: http://www.project1999.com/forums/sh...&postcount=109 P1999 Class Popularity Chart: http://www.project1999.com/forums/sh...7&postcount=48 P1999 PvP Statistics: http://www.project1999.com/forums/sh...9&postcount=59 "Global chat is to conversation what pok books are to travel, but without sufficient population it doesn't matter." | ||
|
Last edited by stormlord; 01-31-2014 at 08:16 PM..
|
|
||
|
#6
|
|||
|
Borland Turbo C++ lol - I used to use that.
He's probably expected to use printf/scanf, not cout/cin and the stream operators as they are from C++.
__________________
Jack <Yael Graduates> - Server First Erudite
Bush <Toxic> Jeremy <TMO> - Patron Saint of Blue | ||
|
|
|||
|
#7
|
||||
|
Quote:
What do you do with programming? I use it as a hobby. I took classes in colllege. My first exposure to it was when I was a sophmore in HS. I was using Qbasic. It's an easy language to start out. Alwys interested to hear from other programmer.
__________________
Full-Time noob. Wipes your windows, joins your groups.
Raiding: http://www.project1999.com/forums/sh...&postcount=109 P1999 Class Popularity Chart: http://www.project1999.com/forums/sh...7&postcount=48 P1999 PvP Statistics: http://www.project1999.com/forums/sh...9&postcount=59 "Global chat is to conversation what pok books are to travel, but without sufficient population it doesn't matter." | |||
|
Last edited by stormlord; 01-31-2014 at 08:48 PM..
|
|
|||
|
#8
|
||||
|
Quote:
thanks to everyone else for all the answers. this assignment isnt due for awhile, but im falling behind in my group due to my confusion. mainly im having a hard time figuring out how to write one algorithm that will print multiple lines based on user-input. ill read through these responses and hopefully i can come up with something.
__________________
![]() | |||
|
Last edited by phacemeltar; 01-31-2014 at 08:20 PM..
Reason: forgive my ignorance of terminology
|
|
|||
|
#9
|
|||
|
you should learn about variables, and then loops =) these are essential for solving this problem
__________________
Jack <Yael Graduates> - Server First Erudite
Bush <Toxic> Jeremy <TMO> - Patron Saint of Blue | ||
|
|
|||
|
#10
|
|||
|
Its been forever since I've done anything with C and I always hated it, so I never got into making elegant solutions. For something suitable you can use these concepts to solve this and then I'll provide some really weakass pseudo-code for you:
Concepts: http://www.learn-c.org/en/Arrays http://www.learn-c.org/en/Strings http://www.learn-c.org/en/For_loops http://www.learn-c.org/en/While_loops (If you don't know about Variables and If-Else statements you should read up on them also). Weakass pseudo-code for the printing of valid input only, stored in a variable called N: Create Char array. print the text "Height: " with the value from N appended after the space. Use a forloop. Your goal here is to Print a line at the end of each cycle until you have printed N lines. Using a while loop here (inside the forloop), your goal is to fill in the appropriate number of Blank spaces in your array and then the appropriate number of hashes. Think about what you can do with an Array and a While loop to accomplish this goal. Hint: If this is the first time the Forloop has ran, you'll want to print N-2 spaces followed by two hashes. After the while loop is finished, before the end of the forloop. Print the array. Edit: After thinking about this a bit more it's possible to do this without an array too, and might be easier for you.
__________________
Baalzy - 57 Gnocro, Baalz - 36 Ikscro, Adra - 51 Hileric, Fatbag Ofcrap - 25 halfuid Red99 Baalz Less - Humger, Baalzy - Ikscro If MMORPG players were around when God said, "Let there be light" they'd have called the light gay, and plunged the universe back into darkness by squatting their nutsacks over it. Picture courtesy of azeth | ||
|
Last edited by baalzy; 01-31-2014 at 08:44 PM..
|
|
||
![]() |
|
|