• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EDT 08:24
CEST 14:24
KST 21:24
  • Home
  • Forum
  • Calendar
  • Streams
  • Liquipedia
  • Features
  • Store
  • EPT
  • TL+
  • StarCraft 2
  • Brood War
  • Smash
  • Heroes
  • Counter-Strike
  • Overwatch
  • Liquibet
  • Fantasy StarCraft
  • TLPD
  • StarCraft 2
  • Brood War
  • Blogs
Forum Sidebar
Events/Features
News
Featured News
[ASL19] Finals Recap: Standing Tall2HomeStory Cup 27 - Info & Preview18Classic wins Code S Season 2 (2025)16Code S RO4 & Finals Preview: herO, Rogue, Classic, GuMiho0TL Team Map Contest #5: Presented by Monster Energy6
Community News
Flash Announces Retirement From ASL18Weekly Cups (June 23-29): Reynor in world title form?12FEL Cracov 2025 (July 27) - $8000 live event16Esports World Cup 2025 - Final Player Roster14Weekly Cups (June 16-22): Clem strikes back1
StarCraft 2
General
The SCII GOAT: A statistical Evaluation What is Lactobacillus used for? Weekly Cups (June 23-29): Reynor in world title form? StarCraft Mass Recall: SC1 campaigns on SC2 thread How does the number of casters affect your enjoyment of esports?
Tourneys
FEL Cracov 2025 (July 27) - $8000 live event HomeStory Cup 27 (June 27-29) WardiTV Mondays SOOPer7s Showmatches 2025 $200 Biweekly - StarCraft Evolution League #1
Strategy
How did i lose this ZvP, whats the proper response Simple Questions Simple Answers
Custom Maps
[UMS] Zillion Zerglings
External Content
Mutation # 480 Moths to the Flame Mutation # 479 Worn Out Welcome Mutation # 478 Instant Karma Mutation # 477 Slow and Steady
Brood War
General
[ASL19] Finals Recap: Standing Tall Flash Announces Retirement From ASL ASL20 Preliminary Maps BW General Discussion BGH Auto Balance -> http://bghmmr.eu/
Tourneys
[Megathread] Daily Proleagues [BSL20] GosuLeague RO16 - Tue & Wed 20:00+CET The Casual Games of the Week Thread [BSL20] ProLeague LB Final - Saturday 20:00 CET
Strategy
Simple Questions, Simple Answers I am doing this better than progamers do.
Other Games
General Games
Stormgate/Frost Giant Megathread Nintendo Switch Thread Path of Exile What do you want from future RTS games? Beyond All Reason
Dota 2
Official 'what is Dota anymore' discussion
League of Legends
Heroes of the Storm
Simple Questions, Simple Answers Heroes of the Storm 2.0
Hearthstone
Heroes of StarCraft mini-set
TL Mafia
TL Mafia Community Thread Vanilla Mini Mafia
Community
General
US Politics Mega-thread Trading/Investing Thread Things Aren’t Peaceful in Palestine Stop Killing Games - European Citizens Initiative Russo-Ukrainian War Thread
Fan Clubs
SKT1 Classic Fan Club! Maru Fan Club
Media & Entertainment
Anime Discussion Thread [Manga] One Piece [\m/] Heavy Metal Thread Korean Music Discussion
Sports
2024 - 2025 Football Thread NBA General Discussion Formula 1 Discussion TeamLiquid Health and Fitness Initiative For 2023 NHL Playoffs 2024
World Cup 2022
Tech Support
Computer Build, Upgrade & Buying Resource Thread
TL Community
The Automated Ban List
Blogs
from making sc maps to makin…
Husyelt
Blog #2
tankgirl
Game Sound vs. Music: The Im…
TrAiDoS
StarCraft improvement
iopq
Heero Yuy & the Tax…
KrillinFromwales
Trip to the Zoo
micronesia
Customize Sidebar...

Website Feedback

Closed Threads



Active: 675 users

The Big Programming Thread - Page 136

Forum Index > General Forum
Post a Reply
Prev 1 134 135 136 137 138 1031 Next
Thread Rules
1. This is not a "do my homework for me" thread. If you have specific questions, ask, but don't post an assignment or homework problem and expect an exact solution.
2. No recruiting for your cockamamie projects (you won't replace facebook with 3 dudes you found on the internet and $20)
3. If you can't articulate why a language is bad, don't start slinging shit about it. Just remember that nothing is worse than making CSS IE6 compatible.
4. Use [code] tags to format code blocks.
BisuDagger
Profile Blog Joined October 2009
Bisutopia19229 Posts
May 11 2012 00:26 GMT
#2701
Anyone know the best way to study phone interview questions for C# overnight? I have an exciting phone screening interview tomorrow and would like to prepare just in case I"m asked some.
ModeratorFormer Afreeca Starleague Caster: http://afreeca.tv/ASL2ENG2
tec27
Profile Blog Joined June 2004
United States3696 Posts
May 11 2012 04:15 GMT
#2702
On May 11 2012 02:37 holdthephone wrote:
What are the best webhosting services? Looking to start up a site and plan to implement a database...

Is GoDaddy the obvious choice?

I've used Site5 for years. They're pretty reliable and cheap as hell
Can you jam with the console cowboys in cyberspace?
Crazyeyes
Profile Blog Joined March 2008
Canada1342 Posts
May 11 2012 04:53 GMT
#2703
So it's now summer, and as a CS student with zero experience of any sort I figure it'd be nice to get some. Making some money in the meantmie would also be neat.
I've been checking local classifieds and stuff, but am having the common problem of 'MINIMUM 5 YEARS EXPERIENCE.'

Anyways, the few jobs I DO find seem overwhelming and scary. All of them involve things I've never done and therefore do not know how to do. I'm afraid to apply for fear that I do get the job and then find myself lost and overwhelmed.

So I'm here hoping to learn that this is common and that my fears are irrational, I guess.
I just wanna have a compsci job ;_;
WeeEEeeEEEeeEEEeeeEEee!!
Element)LoGiC
Profile Joined July 2003
Canada1143 Posts
Last Edited: 2012-05-11 06:55:27
May 11 2012 06:52 GMT
#2704
On May 11 2012 13:53 Crazyeyes wrote:
So it's now summer, and as a CS student with zero experience of any sort I figure it'd be nice to get some. Making some money in the meantmie would also be neat.
I've been checking local classifieds and stuff, but am having the common problem of 'MINIMUM 5 YEARS EXPERIENCE.'

Anyways, the few jobs I DO find seem overwhelming and scary. All of them involve things I've never done and therefore do not know how to do. I'm afraid to apply for fear that I do get the job and then find myself lost and overwhelmed.

So I'm here hoping to learn that this is common and that my fears are irrational, I guess.
I just wanna have a compsci job ;_;


Well, considering you've never actually programmed anything commercial, how many things that people would request do you think you'd be able to do right off the bat?

You only learn when you try things you can't already do. It's normal, and those fears are completely rational. Maybe they do hire you and you can't do it, which is unlikely if you've stuck with programming this long. Hopefully you enjoy it and try it in your spare time and like to learn about it which will make you not only able to do it, but enjoy it.

I would think it worse if you didn't think it overwhelming and scary, which means you may be ignorant to the complexity in some ways.

You'll be fine
leperphilliac
Profile Blog Joined September 2010
United States399 Posts
May 11 2012 06:54 GMT
#2705
What's a good beginner project to work on? I'm thinking about making my own version of tetris and pong which looks really simple (pacman would involve AI and would be next step if tetris/pong work out easily). Would C be a good language for it? I'm most comfortable with C but know C++ Java and Python. Reason for project is because I got rejected from every internship opportunity. It's insane how cutthroat the market is...
Element)LoGiC
Profile Joined July 2003
Canada1143 Posts
May 11 2012 06:56 GMT
#2706
On May 11 2012 15:54 leperphilliac wrote:
What's a good beginner project to work on? I'm thinking about making my own version of tetris and pong which looks really simple (pacman would involve AI and would be next step if tetris/pong work out easily). Would C be a good language for it? I'm most comfortable with C but know C++ Java and Python. Reason for project is because I got rejected from every internship opportunity. It's insane how cutthroat the market is...


What type of job are you looking for? What technologies and languages do you like?
icystorage
Profile Blog Joined November 2008
Jollibee19343 Posts
May 11 2012 07:23 GMT
#2707
+ Show Spoiler +
public static MvcHtmlString ActionLink(this HtmlHelper html, string action, object routeValues)
{
var url = new UrlHelper(html.ViewContext.RequestContext);

// build the <a> tag
var anchorBuilder = new TagBuilder("a");
anchorBuilder.MergeAttribute("href", url.Action(action, routeValues));
anchorBuilder.MergeAttribute("disabled", "true");
string anchorHtml = anchorBuilder.ToString(TagRenderMode.Normal);

return MvcHtmlString.Create(anchorHtml);
}


hi, i got a problem with C#

what i'm trying to do is disabling the link like it is gray'd out and unclickable

i tried searching for it in the web and they said just to set the attribute disabled to true =/ but it doesnt work
LiquidDota StaffAre you ready for a Miracle-? We are! The International 2017 Champions!
e-Goh
Profile Joined January 2012
New Zealand18 Posts
Last Edited: 2012-05-11 09:12:58
May 11 2012 09:11 GMT
#2708
On May 11 2012 16:23 icystorage wrote:
+ Show Spoiler +
public static MvcHtmlString ActionLink(this HtmlHelper html, string action, object routeValues)
{
var url = new UrlHelper(html.ViewContext.RequestContext);

// build the <a> tag
var anchorBuilder = new TagBuilder("a");
anchorBuilder.MergeAttribute("href", url.Action(action, routeValues));
anchorBuilder.MergeAttribute("disabled", "true");
string anchorHtml = anchorBuilder.ToString(TagRenderMode.Normal);

return MvcHtmlString.Create(anchorHtml);
}


hi, i got a problem with C#

what i'm trying to do is disabling the link like it is gray'd out and unclickable

i tried searching for it in the web and they said just to set the attribute disabled to true =/ but it doesnt work


That's some serious convolution in that code you've got there. If it were me, I'd just change the href to # and the style to whatever your css disable link style is. End product: <a href="#" class="a.disabled">blahblah</a>. Dunno how to do that with your multitude of "builders" though. Good thing I'm not a web developer!
icystorage
Profile Blog Joined November 2008
Jollibee19343 Posts
May 11 2012 10:06 GMT
#2709
On May 11 2012 18:11 e-Goh wrote:
Show nested quote +
On May 11 2012 16:23 icystorage wrote:
+ Show Spoiler +
public static MvcHtmlString ActionLink(this HtmlHelper html, string action, object routeValues)
{
var url = new UrlHelper(html.ViewContext.RequestContext);

// build the <a> tag
var anchorBuilder = new TagBuilder("a");
anchorBuilder.MergeAttribute("href", url.Action(action, routeValues));
anchorBuilder.MergeAttribute("disabled", "true");
string anchorHtml = anchorBuilder.ToString(TagRenderMode.Normal);

return MvcHtmlString.Create(anchorHtml);
}


hi, i got a problem with C#

what i'm trying to do is disabling the link like it is gray'd out and unclickable

i tried searching for it in the web and they said just to set the attribute disabled to true =/ but it doesnt work


That's some serious convolution in that code you've got there. If it were me, I'd just change the href to # and the style to whatever your css disable link style is. End product: <a href="#" class="a.disabled">blahblah</a>. Dunno how to do that with your multitude of "builders" though. Good thing I'm not a web developer!

nah its okay, i found it easier making it non anchor and made some conditions in abling and disabling it
LiquidDota StaffAre you ready for a Miracle-? We are! The International 2017 Champions!
ohampatu
Profile Joined July 2010
United States1448 Posts
May 12 2012 16:35 GMT
#2710
I'm back. Im having some issues again. Im trying to create a 'webpage' that will automate monitoring calls for quality. Its only in its rough draft form but I've hit a stump. I have a 'onclick' button that I want to 'generate' my monitor notes. I was thinking like making if else statements for each Y/N answer. That way I can just copy/paste from the output field.

So the problem. I have the 'button' made, but im not a javascript guy, and i dont know of an easy way to write this in HTML using basic input methods. This is a project at work, my IT dept recommended Jquery but no access to that and i move pc's regularly. Any pointers on where i would go from from the beginning, or if the following is just terrible code?

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<script language="JavaScript" type="text/javascript">
<!--
function generate ()




Here is the code:

+ Show Spoiler +

<html><head><title>Monitoring Notes</title>

<table>
<tr><td>
<h1>Monitoring Form</h1>
<h3>Greeting: Makes a connection; Builds the relationship</h3>
<table class="info">
<tr><td>Answers Promptly; Identifies Self and ISP at the beginning of the call</td>
<td><INPUT TYPE="radio" NAME="q1-1" VALUE="y">Yes <INPUT TYPE="radio" NAME="q1-1" VALUE="n">No</td></tr>
<tr><td>Expresses empathy through words and tone; Offers welcoming words</td>
<td><INPUT TYPE="radio" NAME="q1-2" VALUE="y">Yes <INPUT TYPE="radio" NAME="q1-2" VALUE="n">No</td></tr>
<tr><td>Asks for the UN and caller name; Uses AdminTool to lookup user info, asks for ticket #</td>
<td><INPUT TYPE="radio" NAME="q1-3" VALUE="y">Yes <INPUT TYPE="radio" NAME="q1-3" VALUE="n">No</td></tr>
<tr><td>Addresses the caller by name; Starts developing a rapport with the caller</td>
<td><INPUT TYPE="radio" NAME="q1-4" VALUE="y">Yes <INPUT TYPE="radio" NAME="q1-4" VALUE="n">No</td></tr>
<tr><td>Tells the caller they WILL help, or what they CAN do for them</td>
<td><INPUT TYPE="radio" NAME="q1-5" VALUE="y">Yes <INPUT TYPE="radio" NAME="q1-5" VALUE="n">No</td></tr>
</table>
<h3>Professionalism: Acts Professionally; Expresses Confidence</h3>
<table class="info">
<tr><td>Takes ownership of the call and control of the situation; is specific</td>
<td><INPUT TYPE="radio" NAME="q2-1" VALUE="y">Yes <INPUT TYPE="radio" NAME="q2-1" VALUE="n">No</td></tr>
<tr><td>Uses MAGIC phrases to build confidence and trust</td>
<td><INPUT TYPE="radio" NAME="q2-2" VALUE="y">Yes <INPUT TYPE="radio" NAME="q2-2" VALUE="n">No</td></tr>
<tr><td>Expresses sincerity and helpfulness through tone; Maintains a good pace</td>
<td><INPUT TYPE="radio" NAME="q2-3" VALUE="y">Yes <INPUT TYPE="radio" NAME="q2-3" VALUE="n">No</td></tr>
<tr><td>Speaks clearly with proper volume; Avoids tragic phrases</td>
<td><INPUT TYPE="radio" NAME="q2-4" VALUE="y">Yes <INPUT TYPE="radio" NAME="q2-4" VALUE="n">No</td></tr>
<tr><td>Uses Please and Thank You to show courtesy</td>
<td><INPUT TYPE="radio" NAME="q2-5" VALUE="y">Yes <INPUT TYPE="radio" NAME="q2-5" VALUE="n">No</td></tr>
</table>
<h3>Attentiveness: Gets to the Heart of the Matter; Listens and Asks Questions</h3>
<table class="info">
<tr><td>Listens, doesn't interrupt; Rephrases appropriately</td>
<td><INPUT TYPE="radio" NAME="q3-1" VALUE="y">Yes <INPUT TYPE="radio" NAME="q3-1" VALUE="n">No</td></tr>
<tr><td>Uses proper grammar; Avoids the use of slang words or acronyms</td>
<td><INPUT TYPE="radio" NAME="q3-2" VALUE="y">Yes <INPUT TYPE="radio" NAME="q3-2" VALUE="n">No</td></tr>
<tr><td>Asks qualifying questions; Asks for permission to gain more information</td>
<td><INPUT TYPE="radio" NAME="q3-3" VALUE="y">Yes <INPUT TYPE="radio" NAME="q3-3" VALUE="n">No</td></tr>
<tr><td>Before a hold/lag time for transfer; explains why and receives permission</td>
<td><INPUT TYPE="radio" NAME="q3-4" VALUE="y">Yes <INPUT TYPE="radio" NAME="q3-4" VALUE="n">No</td></tr>
<tr><td>After a hold or wait time; uses caller's name, waits for a resopnse, and thanks him/her</td>
<td><INPUT TYPE="radio" NAME="q3-5" VALUE="y">Yes <INPUT TYPE="radio" NAME="q3-5" VALUE="n">No</td></tr>
</table>
<h3>Courtesy & Clarity: Inform, and Clarify what you will do</h3>
<table class="info">
<tr><td>Educates the caller with relevant information</td>
<td><INPUT TYPE="radio" NAME="q3-1" VALUE="y">Yes <INPUT TYPE="radio" NAME="q3-1" VALUE="n">No</td></tr>
<tr><td>Is proactive; offers options or solutions before they are requested</td>
<td><INPUT TYPE="radio" NAME="q3-2" VALUE="y">Yes <INPUT TYPE="radio" NAME="q3-2" VALUE="n">No</td></tr>
<tr><td>Sets a deadline or timeframe before the caller asks</td>
<td><INPUT TYPE="radio" NAME="q3-3" VALUE="y">Yes <INPUT TYPE="radio" NAME="q3-3" VALUE="n">No</td></tr>
<tr><td>Summarizes the next steps</td>
<td><INPUT TYPE="radio" NAME="q3-4" VALUE="y">Yes <INPUT TYPE="radio" NAME="q3-4" VALUE="n">No</td></tr>
<tr><td>Obtains the caller's agreement on the next steps</td>
<td><INPUT TYPE="radio" NAME="q3-5" VALUE="y">Yes <INPUT TYPE="radio" NAME="q3-5" VALUE="n">No</td></tr>
</table>
<h3>Closing: Closes with the Relationship in Mind</h3>
<table class="info">
<tr><td>Offers additional assistance when appropriate; makes last offer to help, offers ticket number</td>
<td><INPUT TYPE="radio" NAME="q4-1" VALUE="y">Yes <INPUT TYPE="radio" NAME="q4-1" VALUE="n">No</td></tr>
<tr><td>Uses the caller's name and a magic phrase in closing</td>
<td><INPUT TYPE="radio" NAME="q4-2" VALUE="y">Yes <INPUT TYPE="radio" NAME="q4-2" VALUE="n">No</td></tr>
<tr><td>Closes with a sincere tone</td>
<td><INPUT TYPE="radio" NAME="q4-3" VALUE="y">Yes <INPUT TYPE="radio" NAME="q4-3" VALUE="n">No</td></tr>
<tr><td>Gives caller their name, brands the call, advises of 24/7 availability</td>
<td><INPUT TYPE="radio" NAME="q4-4" VALUE="y">Yes <INPUT TYPE="radio" NAME="q4-4" VALUE="n">No</td></tr>
<tr><td>Stays with the caller until the end</td>
<td><INPUT TYPE="radio" NAME="q4-5" VALUE="y">Yes <INPUT TYPE="radio" NAME="q4-5" VALUE="n">No</td></tr>
</table>
<h3>Technical Skills & Ability</h3>
<table class="info">
<tr><td>Was able to adequately identify the issue at hand</td>
<td><INPUT TYPE="radio" NAME="q5-1" VALUE="y">Yes <INPUT TYPE="radio" NAME="q5-1" VALUE="n">No</td></tr>
<tr><td>Connection Type/OS of caller was correctly identfied</td>
<td><INPUT TYPE="radio" NAME="q5-2" VALUE="y">Yes <INPUT TYPE="radio" NAME="q5-2" VALUE="n">No</td></tr>
<tr><td>Supported issues within scope of support</td>
<td><INPUT TYPE="radio" NAME="q5-3" VALUE="y">Yes <INPUT TYPE="radio" NAME="q5-3" VALUE="n">No</td></tr>
<tr><td>A correct and logical sequence of events was followed for the issue at hand</td>
<td><INPUT TYPE="radio" NAME="q5-4" VALUE="y">Yes <INPUT TYPE="radio" NAME="q5-4" VALUE="n">No</td></tr>
<tr><td>Able to troubleshoot without assistance and/or Escalated properly</td>
<td><INPUT TYPE="radio" NAME="q5-5" VALUE="y">Yes <INPUT TYPE="radio" NAME="q5-5" VALUE="n">No</td></tr>
<tr><td>Displayed initiative and used skill in moving toward resolution</td>
<td><INPUT TYPE="radio" NAME="q5-6" VALUE="y">Yes <INPUT TYPE="radio" NAME="q5-6" VALUE="n">No</td></tr>
<tr><td>Hold times and Dead air were kept to a minimum</td>
<td><INPUT TYPE="radio" NAME="q5-7" VALUE="y">Yes <INPUT TYPE="radio" NAME="q5-7" VALUE="n">No</td></tr>
<tr><td>All verifications of information were made correctly</td>
<td><INPUT TYPE="radio" NAME="q5-8" VALUE="y">Yes <INPUT TYPE="radio" NAME="q5-8" VALUE="n">No</td></tr>
<tr><td>Timing of the call was acceptable</td>
<td><INPUT TYPE="radio" NAME="q5-9" VALUE="y">Yes <INPUT TYPE="radio" NAME="q5-9" VALUE="n">No</td></tr>
<tr><td>Call Tracker notes are adequate, correct, concise, and clear</td>
<td><INPUT TYPE="radio" NAME="q5-10" VALUE="y">Yes <INPUT TYPE="radio" NAME="q5-10" VALUE="n">No</td></tr>

</table>

</td><td valign="top"><button type="button" onclick="generate()">Generate<br />Feedback<br /></button></td><td valign="top"><textarea name="output" rows="20" cols="20" style="width:400px;height:500px;"></textarea></td></tr>
</table>
<br /><br /><br /><br /><br /><br /><br /><br /><br /><br />
I am become death, for I am the destroyer of worlds.....You will be missed KT Violet!!!
tofucake
Profile Blog Joined October 2009
Hyrule19029 Posts
May 12 2012 16:41 GMT
#2711
use jQuery. It's a single javascript file that sits with the rest of your site's code and will make your life a lot easier.
Liquipediaasante sana squash banana
heroyi
Profile Blog Joined March 2009
United States1064 Posts
Last Edited: 2012-05-14 20:31:11
May 14 2012 14:06 GMT
#2712
whelp I can't figure this out...

I was wondering if someone could help explain to me how to utilize bool in a function form. The reason I ask this is because I am working on this tic tac toe game and am trying to make it so that the game keeps going (asking players to make turns) until it reaches to a halt (three in a row) thus ending the game. I can't figure out how to use the boolean operation to a function form...

Here is the code to help me on:

+ Show Spoiler +


int a = 0;
int b = 0;
int i = 0;

int j = 0;
char tictac[3][3] =
{
{'1','2','3'},
{'4','5','6'},
{'7','8','9'}
};

void board() //intialize board
{
for(i=0;i<3;i++)
{ for(j=0;j<3;j++)
{cout << tictac[i][j] << " " ;}
cout << endl;}
cout << endl;
}


void choice() //to help mark spot for player one
{
if(a == 1)
{ tictac[0][0] = 'X';
board();}

else if(a == 2)
{tictac[0][1] = 'X';
board();}

else if(a == 3)
{tictac[0][2] = 'X';
board();}

else if(a == 4)
{tictac[1][0] = 'X';
board();}

else if(a == 5)
{tictac[1][1] = 'X';
board();}

else if(a == 6)
{tictac[1][2] = 'X';
board();}

else if(a == 7)
{tictac[2][0] = 'X';
board();}

else if(a == 8)
{tictac[2][1] = 'X';
board();}

else if(a == 9)
{tictac[2][2] = 'X';
board();}
}

void choice1() //to help mark spot for player 2
{
if(b == 1)
{tictac[0][0] = 'O';
board();}

else if(b == 2)
{tictac[0][1] = 'O';
board();}

else if(b == 3)
{tictac[0][2] = 'O';
board();}

else if(b == 4)
{tictac[1][0] = 'O';
board();}

else if(b == 5)
{tictac[1][1] = 'O';
board();}

else if(b == 6)
{tictac[1][2] = 'O';
board();}

else if(b == 7)
{tictac[2][0] = 'O';
board();}

else if(b == 8)
{tictac[2][1] = 'O';
board();}

else if(b == 9)
{tictac[2][2] = 'O';
board();}

}



void player1() ]//loop to ask for turn for player 1
{
cout << "Player 1: ";
cin >> a;
while (!cin || a == b) // loop to help catch bad input
{
cout << "choose a different spot: ";
cin.clear();
cin.sync();
cin >> a;
}
choice();
}

void player2() //loop to ask for turn for player 2
{
cout << "Player 2: ";
cin >> b;
while (!cin || a == b) //loop to help catch bad input
{
cout << "choose a different spot: ";
cin.clear();
cin.sync();
cin >> b;
}
choice1();
}



int main()
{

Sleep(2000);
cout << "Lets play tic tac toe between two players" << endl;


for(i=0;i<3;i++) //create board
{for(j=0;j<3;j++)
{cout << tictac[i][j] << " " ;}
cout << endl;}
cout << endl;

Sleep(2000);
cout << "Here is the board. Enter the number to mark your spot." << endl;
cout << "Player 1 is X and player 2 is O." << endl;


cout << "Player 1 goes first. Please enter your number: ";
cin >> a;
choice();
cout << "Player 2: ";
cin >> b;
while (!cin || a == b)
{
cout << "choose a different spot: ";
cin.clear();
cin.sync();
cin >> b;
}
choice1();

[b]//below is the loop/boolean code I am trying to implement but to fail. I have tried different variations and this one here just happens to be the one that I copy and pasted here.[/b]

while(tictac[0][0] == tictac[0][1] != tictac[0][2] || tictac[0][0] == tictac[2][0] != tictac[1][0] || tictac[2][0] == tictac[2][1] != tictac[2][2] || tictac[0][0] != tictac[1][1] == tictac[2][2] || tictac[2][2] != tictac[1][2] == tictac[0][2] )
{player1();
player2();
}


//^^Here I was trying to make it so that as long as three in a row wasn't created then the game would continue in the loop (thus the while loop). However if a three in a row was detected then the statement would become false and would jump out of the loop to "end the game."


{cout << "gg" << endl;} //not the best ending but that isnt the problem.



system("PAUSE");
return 0;


}


appreciate the help
btw fyi: You can ignore some of my coding in the main function (block of code above my comments). I understand it may not be "consistent" but I was more worried on making the code work. Once I can get the whole thing going then I will go around and clean it up a bit to make it nicer.

btw how is my coding "style?" Is there any bad "habits" that I should avoid that is present in my work?
*********


off topic: What situation would call for you to use array over vector? Vectors can do everything an array can but better it seems...is it more efficient to use array on a small memory managment or something?

************

sorry for cluttering :/
wat wat in my pants
MisterD
Profile Blog Joined June 2010
Germany1338 Posts
May 14 2012 14:46 GMT
#2713
boolean is not useless. It might look useless from a computer point of view (and that's why a lot of languages actually define bool only as a type but use int internally to process), but from an engineering point of view, boolean suddenly becomes VERY interesting, because it prohibits prevents a lot more syntax errors by making them actual errors (e.g. if(x = 3) instead of if(x == 3) becomes an error instead of accidentally setting x to 3 and always being true).

protip: have a look at the switch statement instead of your if elseif elseif elseif elseif elseif. Your code is hilariously unreadable :D
Gold isn't everything in life... you need wood, too!
Anacletus
Profile Blog Joined April 2012
United States733 Posts
May 15 2012 12:53 GMT
#2714
teamliquid.net/blogs/viewblog.php?topic_id=337732

I wrote this as a beginner's guide to programming. It is basically a hands-on start for Ruby.

If anyone is interested in learning to program I hope my blog can help!

And for any experienced veterans - feel free to improve and critisize it if you see fit as well.
http://talk-to-stimey-please.1324083.n2.nabble.com/
solidbebe
Profile Blog Joined November 2010
Netherlands4921 Posts
May 15 2012 20:22 GMT
#2715
On May 15 2012 21:53 Anacletus wrote:
teamliquid.net/blogs/viewblog.php?topic_id=337732

I wrote this as a beginner's guide to programming. It is basically a hands-on start for Ruby.

If anyone is interested in learning to program I hope my blog can help!

And for any experienced veterans - feel free to improve and critisize it if you see fit as well.


Wow nice guide asacletun!
That's the 2nd time in a week I've seen someone sig a quote from this GD and I have never witnessed a sig quote happen in my TL history ever before. -Najda
killa_robot
Profile Joined May 2010
Canada1884 Posts
Last Edited: 2012-05-15 20:41:30
May 15 2012 20:40 GMT
#2716
On May 14 2012 23:06 heroyi wrote:
whelp I can't figure this out...

I was wondering if someone could help explain to me how to utilize bool in a function form. The reason I ask this is because I am working on this tic tac toe game and am trying to make it so that the game keeps going (asking players to make turns) until it reaches to a halt (three in a row) thus ending the game. I can't figure out how to use the boolean operation to a function form...

Here is the code to help me on:

+ Show Spoiler +


int a = 0;
int b = 0;
int i = 0;

int j = 0;
char tictac[3][3] =
{
{'1','2','3'},
{'4','5','6'},
{'7','8','9'}
};

void board() //intialize board
{
for(i=0;i<3;i++)
{ for(j=0;j<3;j++)
{cout << tictac[i][j] << " " ;}
cout << endl;}
cout << endl;
}


void choice() //to help mark spot for player one
{
if(a == 1)
{ tictac[0][0] = 'X';
board();}

else if(a == 2)
{tictac[0][1] = 'X';
board();}

else if(a == 3)
{tictac[0][2] = 'X';
board();}

else if(a == 4)
{tictac[1][0] = 'X';
board();}

else if(a == 5)
{tictac[1][1] = 'X';
board();}

else if(a == 6)
{tictac[1][2] = 'X';
board();}

else if(a == 7)
{tictac[2][0] = 'X';
board();}

else if(a == 8)
{tictac[2][1] = 'X';
board();}

else if(a == 9)
{tictac[2][2] = 'X';
board();}
}

void choice1() //to help mark spot for player 2
{
if(b == 1)
{tictac[0][0] = 'O';
board();}

else if(b == 2)
{tictac[0][1] = 'O';
board();}

else if(b == 3)
{tictac[0][2] = 'O';
board();}

else if(b == 4)
{tictac[1][0] = 'O';
board();}

else if(b == 5)
{tictac[1][1] = 'O';
board();}

else if(b == 6)
{tictac[1][2] = 'O';
board();}

else if(b == 7)
{tictac[2][0] = 'O';
board();}

else if(b == 8)
{tictac[2][1] = 'O';
board();}

else if(b == 9)
{tictac[2][2] = 'O';
board();}

}



void player1() ]//loop to ask for turn for player 1
{
cout << "Player 1: ";
cin >> a;
while (!cin || a == b) // loop to help catch bad input
{
cout << "choose a different spot: ";
cin.clear();
cin.sync();
cin >> a;
}
choice();
}

void player2() //loop to ask for turn for player 2
{
cout << "Player 2: ";
cin >> b;
while (!cin || a == b) //loop to help catch bad input
{
cout << "choose a different spot: ";
cin.clear();
cin.sync();
cin >> b;
}
choice1();
}



int main()
{

Sleep(2000);
cout << "Lets play tic tac toe between two players" << endl;


for(i=0;i<3;i++) //create board
{for(j=0;j<3;j++)
{cout << tictac[i][j] << " " ;}
cout << endl;}
cout << endl;

Sleep(2000);
cout << "Here is the board. Enter the number to mark your spot." << endl;
cout << "Player 1 is X and player 2 is O." << endl;


cout << "Player 1 goes first. Please enter your number: ";
cin >> a;
choice();
cout << "Player 2: ";
cin >> b;
while (!cin || a == b)
{
cout << "choose a different spot: ";
cin.clear();
cin.sync();
cin >> b;
}
choice1();

[b]//below is the loop/boolean code I am trying to implement but to fail. I have tried different variations and this one here just happens to be the one that I copy and pasted here.[/b]

while(tictac[0][0] == tictac[0][1] != tictac[0][2] || tictac[0][0] == tictac[2][0] != tictac[1][0] || tictac[2][0] == tictac[2][1] != tictac[2][2] || tictac[0][0] != tictac[1][1] == tictac[2][2] || tictac[2][2] != tictac[1][2] == tictac[0][2] )
{player1();
player2();
}


//^^Here I was trying to make it so that as long as three in a row wasn't created then the game would continue in the loop (thus the while loop). However if a three in a row was detected then the statement would become false and would jump out of the loop to "end the game."


{cout << "gg" << endl;} //not the best ending but that isnt the problem.



system("PAUSE");
return 0;


}


appreciate the help
btw fyi: You can ignore some of my coding in the main function (block of code above my comments). I understand it may not be "consistent" but I was more worried on making the code work. Once I can get the whole thing going then I will go around and clean it up a bit to make it nicer.

btw how is my coding "style?" Is there any bad "habits" that I should avoid that is present in my work?
*********


off topic: What situation would call for you to use array over vector? Vectors can do everything an array can but better it seems...is it more efficient to use array on a small memory managment or something?

************

sorry for cluttering :/


 while(tictac[0][0] == tictac[0][1] != tictac[0][2] || tictac[0][0] == tictac[2][0] != tictac[1][0] || tictac[2][0] == tictac[2][1] != tictac[2][2] || tictac[0][0] != tictac[1][1] == tictac[2][2] || tictac[2][2] != tictac[1][2] == tictac[0][2] ) 


That doesn't work. You can't do A == B != C, you would have to do A == B && B != C.
peacenl
Profile Blog Joined November 2009
550 Posts
Last Edited: 2012-05-15 20:56:52
May 15 2012 20:52 GMT
#2717
Did anyone previously beat the speed of MD5 with their own custom hashing function? The reason for custom hashes I'm trying to use is purely speed, a few collisions or impared security are not an issue. I only need speed because I'm creating hashing tables. I've created the most simple function I can imagine in pseudo code:


to_be_hashed_string(string)
index(string)

Array convert => a=1, b=2, c=3 and so on until z=26
for loop => each substring(to_be_hashed_string, i, 1) start with i = 0
index.add => pow ( convert[substring(to_be_hashed_string, i, 1)], i )
end for



In each iteration the integer i will be incremented which stops many collisions thanks to the Exponentiation (pow) function which is calculated over the convert array number.

string(32) "c18427314aa891c19a3c4e388211eb94" MD5 hash function in 1.8 microseconds
float(1.6514813305334E+29) Custom hash function in 7.1 microseconds
- One does not simply walk into a bar and start calling the shots.
- Failure doesn't mean you are a failure it just means you haven't succeeded yet.
McFortran
Profile Joined October 2010
United States79 Posts
May 15 2012 21:25 GMT
#2718
On May 14 2012 23:06 heroyi wrote:
+ Show Spoiler +
whelp I can't figure this out...

I was wondering if someone could help explain to me how to utilize bool in a function form. The reason I ask this is because I am working on this tic tac toe game and am trying to make it so that the game keeps going (asking players to make turns) until it reaches to a halt (three in a row) thus ending the game. I can't figure out how to use the boolean operation to a function form...

Here is the code to help me on:

+ Show Spoiler +


int a = 0;
int b = 0;
int i = 0;

int j = 0;
char tictac[3][3] =
{
{'1','2','3'},
{'4','5','6'},
{'7','8','9'}
};

void board() //intialize board
{
for(i=0;i<3;i++)
{ for(j=0;j<3;j++)
{cout << tictac[i][j] << " " ;}
cout << endl;}
cout << endl;
}


void choice() //to help mark spot for player one
{
if(a == 1)
{ tictac[0][0] = 'X';
board();}

else if(a == 2)
{tictac[0][1] = 'X';
board();}

else if(a == 3)
{tictac[0][2] = 'X';
board();}

else if(a == 4)
{tictac[1][0] = 'X';
board();}

else if(a == 5)
{tictac[1][1] = 'X';
board();}

else if(a == 6)
{tictac[1][2] = 'X';
board();}

else if(a == 7)
{tictac[2][0] = 'X';
board();}

else if(a == 8)
{tictac[2][1] = 'X';
board();}

else if(a == 9)
{tictac[2][2] = 'X';
board();}
}

void choice1() //to help mark spot for player 2
{
if(b == 1)
{tictac[0][0] = 'O';
board();}

else if(b == 2)
{tictac[0][1] = 'O';
board();}

else if(b == 3)
{tictac[0][2] = 'O';
board();}

else if(b == 4)
{tictac[1][0] = 'O';
board();}

else if(b == 5)
{tictac[1][1] = 'O';
board();}

else if(b == 6)
{tictac[1][2] = 'O';
board();}

else if(b == 7)
{tictac[2][0] = 'O';
board();}

else if(b == 8)
{tictac[2][1] = 'O';
board();}

else if(b == 9)
{tictac[2][2] = 'O';
board();}

}



void player1() ]//loop to ask for turn for player 1
{
cout << "Player 1: ";
cin >> a;
while (!cin || a == b) // loop to help catch bad input
{
cout << "choose a different spot: ";
cin.clear();
cin.sync();
cin >> a;
}
choice();
}

void player2() //loop to ask for turn for player 2
{
cout << "Player 2: ";
cin >> b;
while (!cin || a == b) //loop to help catch bad input
{
cout << "choose a different spot: ";
cin.clear();
cin.sync();
cin >> b;
}
choice1();
}



int main()
{

Sleep(2000);
cout << "Lets play tic tac toe between two players" << endl;


for(i=0;i<3;i++) //create board
{for(j=0;j<3;j++)
{cout << tictac[i][j] << " " ;}
cout << endl;}
cout << endl;

Sleep(2000);
cout << "Here is the board. Enter the number to mark your spot." << endl;
cout << "Player 1 is X and player 2 is O." << endl;


cout << "Player 1 goes first. Please enter your number: ";
cin >> a;
choice();
cout << "Player 2: ";
cin >> b;
while (!cin || a == b)
{
cout << "choose a different spot: ";
cin.clear();
cin.sync();
cin >> b;
}
choice1();

[b]//below is the loop/boolean code I am trying to implement but to fail. I have tried different variations and this one here just happens to be the one that I copy and pasted here.[/b]

while(tictac[0][0] == tictac[0][1] != tictac[0][2] || tictac[0][0] == tictac[2][0] != tictac[1][0] || tictac[2][0] == tictac[2][1] != tictac[2][2] || tictac[0][0] != tictac[1][1] == tictac[2][2] || tictac[2][2] != tictac[1][2] == tictac[0][2] )
{player1();
player2();
}


//^^Here I was trying to make it so that as long as three in a row wasn't created then the game would continue in the loop (thus the while loop). However if a three in a row was detected then the statement would become false and would jump out of the loop to "end the game."


{cout << "gg" << endl;} //not the best ending but that isnt the problem.



system("PAUSE");
return 0;


}


appreciate the help
btw fyi: You can ignore some of my coding in the main function (block of code above my comments). I understand it may not be "consistent" but I was more worried on making the code work. Once I can get the whole thing going then I will go around and clean it up a bit to make it nicer.

btw how is my coding "style?" Is there any bad "habits" that I should avoid that is present in my work?
*********


off topic: What situation would call for you to use array over vector? Vectors can do everything an array can but better it seems...is it more efficient to use array on a small memory managment or something?

************

sorry for cluttering :/

I'm terrible at programming, so I won't comment on much, but it seems like your choice() function can be replaced with:
+ Show Spoiler +
void choice()
{
tictac[(a-1)/3][(a-1)%3]='X';
board();
}

also, are you using global variables? Otherwise wouldn't you need choice(int a) instead of choice()?
MisterD
Profile Blog Joined June 2010
Germany1338 Posts
Last Edited: 2012-05-15 22:19:08
May 15 2012 22:17 GMT
#2719
On May 16 2012 05:52 peacenl wrote:
Did anyone previously beat the speed of MD5 with their own custom hashing function? The reason for custom hashes I'm trying to use is purely speed, a few collisions or impared security are not an issue. I only need speed because I'm creating hashing tables. I've created the most simple function I can imagine in pseudo code:


to_be_hashed_string(string)
index(string)

Array convert => a=1, b=2, c=3 and so on until z=26
for loop => each substring(to_be_hashed_string, i, 1) start with i = 0
index.add => pow ( convert[substring(to_be_hashed_string, i, 1)], i )
end for



In each iteration the integer i will be incremented which stops many collisions thanks to the Exponentiation (pow) function which is calculated over the convert array number.

string(32) "c18427314aa891c19a3c4e388211eb94" MD5 hash function in 1.8 microseconds
float(1.6514813305334E+29) Custom hash function in 7.1 microseconds


stick to int, don't use float, that's stupid if you're aiming for speed also, try less cluttering. a simple:

int hash(String string) {
int hash = 0;
for(char c : string) {
hash = hash * 31 + (int)c;
}
return hash;
}


will probably suffice. Also, if you recalculate hashes for the same string repeatedly without mutating the string inbetween, it might help to use a wrapper data structure, which calculates the hash value on creation and caches it. Then you can simply reuse it and don't have to recalculate over and over.
Gold isn't everything in life... you need wood, too!
Sad[Panda]
Profile Blog Joined January 2009
United States458 Posts
May 16 2012 08:36 GMT
#2720
Hey everyone ive recently been becoming more and more interested in learning the C language as a start point as personally I just really love the thought of being able to just create things Id need or just want to (hell even maybe at some point make some PSP or DS homebrews for myself as a little project too). I have a PDF book on C and I want to get myself more familiar with Linux.

ATM I have Ubuntu installed but I feel like its to Noob friendly in the sense that I dont feel pressured to actually have to get used to terminal am I being ignorant? Is there any other Linux distros that would be better to force me to learn things without being completely thrown down a creek with no paddle? A friend told me Gentoo if I want hard times since you are forced to compile everything and another said Debian but didnt really elaborate

also whats your guys Distro of choice?
( O.O) ("\(t.t )/") ~ I'm just looking for someone to hug
Prev 1 134 135 136 137 138 1031 Next
Please log in or register to reply.
Live Events Refresh
Next event in 3h 36m
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
Harstem 294
RotterdaM 244
EnDerr 32
ForJumy 21
StarCraft: Brood War
Rain 6094
Sea 4705
Larva 600
EffOrt 532
Mini 455
Pusan 343
BeSt 311
Stork 290
Zeus 262
Last 193
[ Show more ]
Snow 148
Mind 142
ZerO 122
Hyun 112
Rush 87
Light 66
hero 63
JYJ46
Aegong 43
Movie 29
Sharp 23
NaDa 18
sSak 14
Noble 12
Barracks 10
ajuk12(nOOB) 10
scan(afreeca) 9
IntoTheRainbow 8
Icarus 7
SilentControl 7
HiyA 6
Hm[arnc] 3
Britney 0
Stormgate
NightEnD11
Dota 2
Gorgc4210
qojqva1549
BananaSlamJamma537
XcaliburYe421
febbydoto6
League of Legends
singsing2123
Counter-Strike
x6flipin599
markeloff54
Super Smash Bros
Mew2King160
Westballz12
Heroes of the Storm
Khaldor178
Other Games
B2W.Neo740
DeMusliM501
Fuzer 474
hiko260
Pyrionflax252
XaKoH 251
crisheroes215
SortOf93
ArmadaUGS41
ZerO(Twitch)7
Organizations
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 13 non-featured ]
StarCraft 2
• StrangeGG 40
• AfreecaTV YouTube
• intothetv
• Kozan
• IndyKCrew
• LaughNgamezSOOP
• Migwel
• sooper7s
StarCraft: Brood War
• iopq 2
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
Dota 2
• C_a_k_e 1178
Upcoming Events
uThermal 2v2 Circuit
3h 36m
OSC
6h 36m
Replay Cast
11h 36m
The PondCast
21h 36m
RSL Revival
21h 36m
ByuN vs Classic
Clem vs Cham
WardiTV European League
1d 3h
Replay Cast
1d 11h
RSL Revival
1d 21h
herO vs SHIN
Reynor vs Cure
WardiTV European League
2 days
FEL
2 days
[ Show More ]
Korean StarCraft League
2 days
CranKy Ducklings
2 days
RSL Revival
2 days
FEL
3 days
Sparkling Tuna Cup
3 days
RSL Revival
3 days
FEL
3 days
BSL: ProLeague
4 days
Dewalt vs Bonyth
Replay Cast
5 days
Replay Cast
5 days
The PondCast
6 days
Liquipedia Results

Completed

Proleague 2025-06-28
HSC XXVII
Heroes 10 EU

Ongoing

JPL Season 2
BSL 2v2 Season 3
BSL Season 20
Acropolis #3
KCM Race Survival 2025 Season 2
CSL 17: 2025 SUMMER
Copa Latinoamericana 4
Championship of Russia 2025
RSL Revival: Season 1
Murky Cup #2
BLAST.tv Austin Major 2025
ESL Impact League Season 7
IEM Dallas 2025
PGL Astana 2025
Asian Champions League '25
BLAST Rivals Spring 2025
MESA Nomadic Masters
CCT Season 2 Global Finals
IEM Melbourne 2025
YaLLa Compass Qatar 2025

Upcoming

CSLPRO Last Chance 2025
CSLPRO Chat StarLAN 3
K-Championship
uThermal 2v2 Main Event
SEL Season 2 Championship
FEL Cracov 2025
Esports World Cup 2025
StarSeries Fall 2025
FISSURE Playground #2
BLAST Open Fall 2025
BLAST Open Fall Qual
Esports World Cup 2025
BLAST Bounty Fall 2025
BLAST Bounty Fall Qual
IEM Cologne 2025
FISSURE Playground #1
TLPD

1. ByuN
2. TY
3. Dark
4. Solar
5. Stats
6. Nerchio
7. sOs
8. soO
9. INnoVation
10. Elazer
1. Rain
2. Flash
3. EffOrt
4. Last
5. Bisu
6. Soulkey
7. Mini
8. Sharp
Sidebar Settings...

Advertising | Privacy Policy | Terms Of Use | Contact Us

Original banner artwork: Jim Warren
The contents of this webpage are copyright © 2025 TLnet. All Rights Reserved.