How To Write A Blackjack Program In C
2021年4月23日Register here: http://gg.gg/p5afk
20 Dec 2010
*How To Write A Blackjack Program In Construction
I’ve been trying to look around for projects to do in C to gain programming experience but I can’t really find any. Can anyone here suggest any programming projects a non-expert in C can do? Or would working through this class be a good way to start. I am working on this blackjack game and i facing some problems that i can’t find the soulotion, i hope someone can help me. The code is unfisished yet, but one of the main problems i have is how to print the cards, i wrote a function that is supossed to do this but i am having a touble using it in the code. A blackjack program I wrote in C, it’s kind of awful - blackjack.cpp.
Now I’d like to share one of my experience of programming C.
Our teacher gave us a task: to finish a small but not so useless program by our own in C. He gave three options and unluckily, I was so confident that I chose the most difficult one: to write a program of Blackjack (simplified though, without money involved), also known as Twenty-one, played in command line.
It is a disaster. Though I scanned lots of programming books, however, I haven’t really finished a useful project before. In this task, I strongly realize how stupid I am.
First of all, I don’t know the way to shuffle the 52 cards. Their order requires random, no repeat, and easy to access. “Array”, you must say. However, I didn’t exactly understand how it works in C, and I had to find out the algorithm, which our teacher didn’t tell us. And after I found the answer to the algorithm, I was trapped in the pointers and arrays, and my poor understanding to function in C forced me to face strange warnings and errors. I wasted long long time to debug the shuffle_cards() function, though in the end I realized how simple it is.
Secondly, too many branches in the game exactly annoyed me a lot. There are too many possible results of the game, due to its rules. So I had to use lots of if(){}else{} statement, which results in ugly look and slow performance.
Finally, problems occur when I want to compile the code. I develop it in Ubuntu Linux, and gcc works fine. But it seems that Visual C++ 6.0 doesn’t like the code! Luckily I found alternative compiler in Windows: Dev C++ and Tiny C Compiler. And I finished it now. They are ugly and unclean codes. :-(
It is an unforgettable experience. Well, anyway, after all, I dare to say I have developed in C now!
I have uploaded it to https://github.com/fyears/simple-Black-Jack now.Related PostsHow To Write A Blackjack Program In ConstructionPlease enable JavaScript to view the comments powered by Disqus.
Register here: http://gg.gg/p5afk
https://diarynote.indered.space
20 Dec 2010
*How To Write A Blackjack Program In Construction
I’ve been trying to look around for projects to do in C to gain programming experience but I can’t really find any. Can anyone here suggest any programming projects a non-expert in C can do? Or would working through this class be a good way to start. I am working on this blackjack game and i facing some problems that i can’t find the soulotion, i hope someone can help me. The code is unfisished yet, but one of the main problems i have is how to print the cards, i wrote a function that is supossed to do this but i am having a touble using it in the code. A blackjack program I wrote in C, it’s kind of awful - blackjack.cpp.
Now I’d like to share one of my experience of programming C.
Our teacher gave us a task: to finish a small but not so useless program by our own in C. He gave three options and unluckily, I was so confident that I chose the most difficult one: to write a program of Blackjack (simplified though, without money involved), also known as Twenty-one, played in command line.
It is a disaster. Though I scanned lots of programming books, however, I haven’t really finished a useful project before. In this task, I strongly realize how stupid I am.
First of all, I don’t know the way to shuffle the 52 cards. Their order requires random, no repeat, and easy to access. “Array”, you must say. However, I didn’t exactly understand how it works in C, and I had to find out the algorithm, which our teacher didn’t tell us. And after I found the answer to the algorithm, I was trapped in the pointers and arrays, and my poor understanding to function in C forced me to face strange warnings and errors. I wasted long long time to debug the shuffle_cards() function, though in the end I realized how simple it is.
Secondly, too many branches in the game exactly annoyed me a lot. There are too many possible results of the game, due to its rules. So I had to use lots of if(){}else{} statement, which results in ugly look and slow performance.
Finally, problems occur when I want to compile the code. I develop it in Ubuntu Linux, and gcc works fine. But it seems that Visual C++ 6.0 doesn’t like the code! Luckily I found alternative compiler in Windows: Dev C++ and Tiny C Compiler. And I finished it now. They are ugly and unclean codes. :-(
It is an unforgettable experience. Well, anyway, after all, I dare to say I have developed in C now!
I have uploaded it to https://github.com/fyears/simple-Black-Jack now.Related PostsHow To Write A Blackjack Program In ConstructionPlease enable JavaScript to view the comments powered by Disqus.
Register here: http://gg.gg/p5afk
https://diarynote.indered.space
コメント