Upvote Upvoted 31 Downvote Downvoted
1 2 3
help me with my coding hw
posted in Off Topic
1
#1
0 Frags +

c++, using visual studio pro
supposed to make a simple hangman code only using IF, loops, switch, and string

#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>

using namespace std;
using::std::string;

int main()
{
	string secret = "hi";
	string answer = "__";
	char letter;
	int incorrect=7;

	cout << "enter a letter." << endl;
	cout << answer << endl;
	cin >> letter;
	switch (letter)
	{
	case 'h':
		for (letter;letter='h';letter){
		cout << "correct!" << endl;
			answer.erase (1,1);
			answer.replace (1,1,"h");
		}while (letter='h');
			cout << "please guess again." << endl;
			cin >> letter;

	case 'i':
		for  (letter;letter='i';letter){
		cout << "correct!" << endl;
			answer.erase (2,1);
			answer.replace (2,1,"i");
	}while (letter='i');
			cout << "please guess again." << endl;
			cin >> letter;

	default:
		for (letter;letter!='h'&&'i';letter){
		cout << "incorrect!" << endl;
		cout << "You have " << incorrect << " more guesses left." << endl;
		incorrect--;
	}while (letter!='h'&&'i' && incorrect>0);
		cout << "please guess again." << endl;
		cin >> letter;
	}
	switch (incorrect)
	{
		case 0:
			cout << "you lose!" << endl;
	}
		system ("pause");
		return(0);

}

full instructions:

Show Content
1. Create a string variable for the secret word
2. Create a string variable for the answer
3. Create a char variable for the letter the user will guess
4. Ask the user to enter a letter
5. Place this in a loop so the user can enter another letter
6. Use Replace command to replace correct letter guessed with letters of secret word.
7. Stop the program and “hang” the user after 7 incorrect guesses or win
when the user guesses the correct word

thx

c++, using visual studio pro
supposed to make a simple hangman code only using IF, loops, switch, and string

[code]#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>

using namespace std;
using::std::string;

int main()
{
string secret = "hi";
string answer = "__";
char letter;
int incorrect=7;

cout << "enter a letter." << endl;
cout << answer << endl;
cin >> letter;
switch (letter)
{
case 'h':
for (letter;letter='h';letter){
cout << "correct!" << endl;
answer.erase (1,1);
answer.replace (1,1,"h");
}while (letter='h');
cout << "please guess again." << endl;
cin >> letter;

case 'i':
for (letter;letter='i';letter){
cout << "correct!" << endl;
answer.erase (2,1);
answer.replace (2,1,"i");
}while (letter='i');
cout << "please guess again." << endl;
cin >> letter;

default:
for (letter;letter!='h'&&'i';letter){
cout << "incorrect!" << endl;
cout << "You have " << incorrect << " more guesses left." << endl;
incorrect--;
}while (letter!='h'&&'i' && incorrect>0);
cout << "please guess again." << endl;
cin >> letter;
}
switch (incorrect)
{
case 0:
cout << "you lose!" << endl;
}
system ("pause");
return(0);

}[/code]

full instructions:
[spoiler]1. Create a string variable for the secret word
2. Create a string variable for the answer
3. Create a char variable for the letter the user will guess
4. Ask the user to enter a letter
5. Place this in a loop so the user can enter another letter
6. Use Replace command to replace correct letter guessed with letters of secret word.
7. Stop the program and “hang” the user after 7 incorrect guesses or win
when the user guesses the correct word
[/spoiler]
thx
2
#2
19 Frags +

http://stackoverflow.com/

http://stackoverflow.com/
3
#3
27 Frags +

not a professional in any regard, but i'll attempt anyway:

if wrong; "u lose"
if right "u win"
stop program

your welcome! (this line is not part of code btw)

not a professional in any regard, but i'll attempt anyway:

if wrong; "u lose"
if right "u win"
stop program

your welcome! (this line is not part of code btw)
4
#4
3 Frags +

Break it down into individual tasks, as simple as you can, then solve them one by one.

If you don't know something you need to know in order to complete one of the tasks, google it. You're better off working through coding stuff yourself, even if it takes lots of searching on google to figure out how it works

Break it down into individual tasks, as simple as you can, then solve them one by one.

If you don't know something you need to know in order to complete one of the tasks, google it. You're better off working through coding stuff yourself, even if it takes lots of searching on google to figure out how it works
5
#5
24 Frags +

OK, step 1 is that you definitely need to put on a dress first

https://my.mixtape.moe/cbxhwf.png

After doing this you should be able to find and fix your other mistakes

OK, step 1 is that you definitely need to put on a dress first
[img]https://my.mixtape.moe/cbxhwf.png[/img]

After doing this you should be able to find and fix your other mistakes
6
#6
-4 Frags +

switches are dumb and meaningless for intro 1

use if and else if statements so it isnt an eye sore and then i can probably help

switches are dumb and meaningless for intro 1

use if and else if statements so it isnt an eye sore and then i can probably help
7
#7
6 Frags +

i havent read through the code that closely (plus im not familiar with c really) so im not sure if there's errors in it but your code isn't structured very well. think about how hard it would be to modify to use a word different to "hi", or god forbid a word with more than 2 letters

a better way of structuring it is to loop over the string comparing each letter to the input you got then modifying the 'answer' string. you should put that inside another loop (while incorrect > 0) so you can support words longer than 2 letters easily

if you wanna prevent old letters from being reentered you should store them in a 'guesses' string (since you cant use arrays) and check it after getting the input

i havent read through the code that closely (plus im not familiar with c really) so im not sure if there's errors in it but your code isn't structured very well. think about how hard it would be to modify to use a word different to "hi", or god forbid a word with more than 2 letters

a better way of structuring it is to loop over the string comparing each letter to the input you got then modifying the 'answer' string. you should put that inside another loop (while incorrect > 0) so you can support words longer than 2 letters easily

if you wanna prevent old letters from being reentered you should store them in a 'guesses' string (since you cant use arrays) and check it after getting the input
8
#8
57 Frags +

I don't know C++, but here's a Python3 solution.
http://ideone.com/gPxXvX

secret = "test"
wrongCount = 0
maxWrongGuess = 7
while True:
	guess = str(input('Guess letter: '))
	if (guess in secret):
		print(guess + " was in the word!")
		secret = ''.join(secret.split(guess))
	else:
		print("Not in word")
		wrongCount += 1
	if (len(secret) == 0):
		print("You won!")
		break
	if (wrongCount >= maxWrongGuess):
		print("You're literal garbage")
		break
I don't know C++, but here's a Python3 solution.
http://ideone.com/gPxXvX

[code]secret = "test"
wrongCount = 0
maxWrongGuess = 7
while True:
guess = str(input('Guess letter: '))
if (guess in secret):
print(guess + " was in the word!")
secret = ''.join(secret.split(guess))
else:
print("Not in word")
wrongCount += 1
if (len(secret) == 0):
print("You won!")
break
if (wrongCount >= maxWrongGuess):
print("You're literal garbage")
break
[/code]
9
#9
SizzlingStats
61 Frags +

I don't know C++, but here's a Lua solution.
http://ideone.com/dBBQvl

local secret = "hi"
local answer = "__"

for i=0,6,1 do
	local fuck = secret:gsub(io.read(), "_")
	for j=1,#fuck do
		if fuck:sub(j,j) == "_" then
			answer = answer:sub(1, j-1) .. secret:sub(j,j) .. answer:sub(j+1)
		end
	end
	print(answer)
	if answer == secret then
		print("You win")
		break
	end
end
print("The word was "..secret)
I don't know C++, but here's a Lua solution.
http://ideone.com/dBBQvl
[code]
local secret = "hi"
local answer = "__"

for i=0,6,1 do
local fuck = secret:gsub(io.read(), "_")
for j=1,#fuck do
if fuck:sub(j,j) == "_" then
answer = answer:sub(1, j-1) .. secret:sub(j,j) .. answer:sub(j+1)
end
end
print(answer)
if answer == secret then
print("You win")
break
end
end
print("The word was "..secret)[/code]
10
#10
SizzlingStats
61 Frags +

I don't know C++, but here's a Javascript solution.
https://jsfiddle.net/ntLxjq59/

secret='ayy'
answer='___'
mistakeCount=0
maxMistakeCount=7

function fuck() {
  alert("clue: "+answer)
  shit(prompt("Guess a letter")) || mistakeCount++
}

function shit(c) {
  if (!c.length) return false
  s = secret.split('')
  a = answer.split('')
  b = false
  for (i=0; i<secret.length; i++)
    c==s[i] && (b=true, a[i]=c)
  answer=a.join('')
  return b
}

while (answer!=secret && maxMistakeCount>mistakeCount) fuck()

window.alert(answer==secret ? 'you win' : 'fuck you')
I don't know C++, but here's a Javascript solution.
https://jsfiddle.net/ntLxjq59/

[code]
secret='ayy'
answer='___'
mistakeCount=0
maxMistakeCount=7

function fuck() {
alert("clue: "+answer)
shit(prompt("Guess a letter")) || mistakeCount++
}

function shit(c) {
if (!c.length) return false
s = secret.split('')
a = answer.split('')
b = false
for (i=0; i<secret.length; i++)
c==s[i] && (b=true, a[i]=c)
answer=a.join('')
return b
}

while (answer!=secret && maxMistakeCount>mistakeCount) fuck()

window.alert(answer==secret ? 'you win' : 'fuck you')
[/code]
11
#11
14 Frags +

are those weirdly nerdy synchronised posts

are those weirdly nerdy synchronised posts
12
#12
SizzlingStats
65 Frags +

I don't know C++, but here's a C solution.
http://ideone.com/nwIobI

#include <stdio.h>

const int NUM_GUESSES = 7;
const char SECRET[] = "hi";

#define F 0
#define T 1

const int asdf[3][256] =
{
    {
        F, 0, 0, 0, 0, 0, 0, F,
        0, F, 0, 0, 0, 0, F, 0,
        0, 0, F, 0, 0, F, 0, 0,
        0, 0, 0, F, F, 0, 0, 0,
        0, 0, 0, F, F, 0, 0, 0,
        0, 0, F, 0, 0, F, 0, 0,
        0, F, 0, 0, 0, 0, F, 0,
        F, 0, 0, 0, 0, 0, 0, F,
        0, F, 0, 0, 0, 0, F, 0,
        0, 0, F, 0, 0, F, 0, 0,
        0, 0, 0, F, F, 0, 0, 0,
        0, 0, 0, F, F, 0, 0, 0,
        0, 0, F, 0, 0, F, 0, 0,
        1, T, 0, 0, 0, 0, F, 0,
        F, 0, 0, 0, 0, 0, 0, F,
        0, F, 0, 0, 0, 0, F, 0,
        0, 0, F, 0, 0, F, 0, 0,
        0, 0, 0, F, F, 0, 0, 0,
        0, 0, 0, F, F, 0, 0, 0,
        0, 0, F, 0, 0, F, 0, 0,
        0, F, 0, 0, 0, 0, F, 0,
        F, 0, 0, 0, 0, 0, 0, F,
        0, F, 0, 0, 0, 0, F, 0,
        0, 0, F, 0, 0, F, 0, 0,
        0, 0, 0, F, F, 0, 0, 0,
        0, 0, 0, F, F, 0, 0, 0,
        0, 0, F, 0, 0, F, 0, 0,
        0, F, 0, 0, 0, 0, F, 0,
        F, 0, 0, 0, 0, 0, 0, F,
        0, F, 0, 0, 0, 0, F, 0,
        0, 0, F, 0, 0, F, 0, 0,
        0, 0, 0, F, F, 0, 0, 0
    },
    {
        0, F, 0, F, F, 0, F, 0,
        0, F, 0, F, F, 0, F, 0,
        0, F, 0, F, F, 0, F, 0,
        0, F, 0, F, F, 0, F, 0,
        0, F, 0, F, F, 0, F, 0,
        0, F, 0, F, F, 0, F, 0,
        0, F, 0, F, F, 0, F, 0,
        0, F, 0, F, F, 0, F, 0,
        0, 0, F, 0, 0, F, 0, 0,
        0, 0, F, 0, 0, F, 0, 0,
        0, 0, F, 0, 0, F, 0, 0,
        0, 0, F, 0, 0, F, 0, 0,
        0, 0, F, 0, 0, F, 0, 0,
        0, 1, F, 0, 0, F, 0, 0,
        0, 0, F, 0, 0, F, 0, 0,
        0, 0, F, 0, 0, F, 0, 0,
        0, 0, 0, F, F, 0, 0, 0,
        0, 0, 0, F, F, 0, 0, 0,
        0, 0, 0, F, F, 0, 0, 0,
        0, 0, 0, F, F, 0, 0, 0,
        0, 0, 0, F, F, 0, 0, 0,
        0, 0, 0, F, F, 0, 0, 0,
        0, 0, 0, F, F, 0, 0, 0,
        0, 0, 0, F, F, 0, 0, 0,
        0, 0, F, 0, 0, F, 0, 0,
        0, 0, F, 0, 0, F, 0, 0,
        0, 0, F, 0, 0, F, 0, 0,
        0, 0, F, 0, 0, F, 0, 0,
        0, 0, F, 0, 0, F, 0, 0,
        0, 0, F, 0, 0, F, 0, 0,
        0, 0, F, 0, 0, F, 0, 0,
        0, 0, F, 0, 0, F, 0, 0
    },
    {
        F, 0, F, 0, F, 0, F, 0,
        0, F, 0, F, 0, F, 0, F,
        0, 0, F, 0, F, 0, F, 0,
        0, 0, 0, F, 0, F, 0, F,
        F, 0, 0, 0, F, 0, F, 0,
        0, F, 0, 0, 0, F, 0, F,
        F, 0, F, 0, 0, 0, F, 0,
        0, F, 0, F, 0, 0, 0, F,
        F, 0, F, 0, F, 0, 0, 0,
        0, F, 0, F, 0, F, 0, 0,
        F, 0, F, 0, F, 0, F, 0,
        0, F, 0, F, 0, F, 0, F,
        0, 0, F, 0, F, 0, F, 0,
        1, 0, 0, F, 0, F, 0, F,
        F, 0, 0, 0, F, 0, F, 0,
        0, F, 0, 0, 0, F, 0, F,
        F, 0, F, 0, 0, 0, F, 0,
        0, F, 0, F, 0, 0, 0, F,
        F, 0, F, 0, F, 0, 0, 0,
        0, F, 0, F, 0, F, 0, 0,
        F, 0, F, 0, F, 0, F, 0,
        0, F, 0, F, 0, F, 0, F,
        0, 0, F, 0, F, 0, F, 0,
        0, 0, 0, F, 0, F, 0, F,
        F, 0, 0, 0, F, 0, F, 0,
        0, F, 0, 0, 0, F, 0, F,
        F, 0, F, 0, 0, 0, F, 0,
        0, F, 0, F, 0, 0, 0, F,
        F, 0, F, 0, F, 0, 0, 0,
        0, F, 0, F, 0, F, 0, 0,
        F, 0, F, 0, F, 0, F, 0,
        0, F, 0, F, 0, F, 0, F
    }
};

int main()
{
    char answer[] = "__";
    unsigned int hehehe = 0;

    for (int i = 0; i < NUM_GUESSES; ++i)
    {
        printf("Enter a letter. %s\n", answer);
        char guess = getchar();
        getchar();

        if(asdf[hehehe][guess])
        {
            int efef = (guess - SECRET[0]);
            answer[efef] = SECRET[efef];
            hehehe |= (1 << efef);
        }
        else
        {
            printf("Letter not found, try again\n");
        }

        if (hehehe == 3)
        {
            printf("You win\n");
            break;
        }
    }

    printf("The word was %s\n", SECRET);
    return 0;
}
I don't know C++, but here's a C solution.
http://ideone.com/nwIobI
[code]
#include <stdio.h>

const int NUM_GUESSES = 7;
const char SECRET[] = "hi";

#define F 0
#define T 1

const int asdf[3][256] =
{
{
F, 0, 0, 0, 0, 0, 0, F,
0, F, 0, 0, 0, 0, F, 0,
0, 0, F, 0, 0, F, 0, 0,
0, 0, 0, F, F, 0, 0, 0,
0, 0, 0, F, F, 0, 0, 0,
0, 0, F, 0, 0, F, 0, 0,
0, F, 0, 0, 0, 0, F, 0,
F, 0, 0, 0, 0, 0, 0, F,
0, F, 0, 0, 0, 0, F, 0,
0, 0, F, 0, 0, F, 0, 0,
0, 0, 0, F, F, 0, 0, 0,
0, 0, 0, F, F, 0, 0, 0,
0, 0, F, 0, 0, F, 0, 0,
1, T, 0, 0, 0, 0, F, 0,
F, 0, 0, 0, 0, 0, 0, F,
0, F, 0, 0, 0, 0, F, 0,
0, 0, F, 0, 0, F, 0, 0,
0, 0, 0, F, F, 0, 0, 0,
0, 0, 0, F, F, 0, 0, 0,
0, 0, F, 0, 0, F, 0, 0,
0, F, 0, 0, 0, 0, F, 0,
F, 0, 0, 0, 0, 0, 0, F,
0, F, 0, 0, 0, 0, F, 0,
0, 0, F, 0, 0, F, 0, 0,
0, 0, 0, F, F, 0, 0, 0,
0, 0, 0, F, F, 0, 0, 0,
0, 0, F, 0, 0, F, 0, 0,
0, F, 0, 0, 0, 0, F, 0,
F, 0, 0, 0, 0, 0, 0, F,
0, F, 0, 0, 0, 0, F, 0,
0, 0, F, 0, 0, F, 0, 0,
0, 0, 0, F, F, 0, 0, 0
},
{
0, F, 0, F, F, 0, F, 0,
0, F, 0, F, F, 0, F, 0,
0, F, 0, F, F, 0, F, 0,
0, F, 0, F, F, 0, F, 0,
0, F, 0, F, F, 0, F, 0,
0, F, 0, F, F, 0, F, 0,
0, F, 0, F, F, 0, F, 0,
0, F, 0, F, F, 0, F, 0,
0, 0, F, 0, 0, F, 0, 0,
0, 0, F, 0, 0, F, 0, 0,
0, 0, F, 0, 0, F, 0, 0,
0, 0, F, 0, 0, F, 0, 0,
0, 0, F, 0, 0, F, 0, 0,
0, 1, F, 0, 0, F, 0, 0,
0, 0, F, 0, 0, F, 0, 0,
0, 0, F, 0, 0, F, 0, 0,
0, 0, 0, F, F, 0, 0, 0,
0, 0, 0, F, F, 0, 0, 0,
0, 0, 0, F, F, 0, 0, 0,
0, 0, 0, F, F, 0, 0, 0,
0, 0, 0, F, F, 0, 0, 0,
0, 0, 0, F, F, 0, 0, 0,
0, 0, 0, F, F, 0, 0, 0,
0, 0, 0, F, F, 0, 0, 0,
0, 0, F, 0, 0, F, 0, 0,
0, 0, F, 0, 0, F, 0, 0,
0, 0, F, 0, 0, F, 0, 0,
0, 0, F, 0, 0, F, 0, 0,
0, 0, F, 0, 0, F, 0, 0,
0, 0, F, 0, 0, F, 0, 0,
0, 0, F, 0, 0, F, 0, 0,
0, 0, F, 0, 0, F, 0, 0
},
{
F, 0, F, 0, F, 0, F, 0,
0, F, 0, F, 0, F, 0, F,
0, 0, F, 0, F, 0, F, 0,
0, 0, 0, F, 0, F, 0, F,
F, 0, 0, 0, F, 0, F, 0,
0, F, 0, 0, 0, F, 0, F,
F, 0, F, 0, 0, 0, F, 0,
0, F, 0, F, 0, 0, 0, F,
F, 0, F, 0, F, 0, 0, 0,
0, F, 0, F, 0, F, 0, 0,
F, 0, F, 0, F, 0, F, 0,
0, F, 0, F, 0, F, 0, F,
0, 0, F, 0, F, 0, F, 0,
1, 0, 0, F, 0, F, 0, F,
F, 0, 0, 0, F, 0, F, 0,
0, F, 0, 0, 0, F, 0, F,
F, 0, F, 0, 0, 0, F, 0,
0, F, 0, F, 0, 0, 0, F,
F, 0, F, 0, F, 0, 0, 0,
0, F, 0, F, 0, F, 0, 0,
F, 0, F, 0, F, 0, F, 0,
0, F, 0, F, 0, F, 0, F,
0, 0, F, 0, F, 0, F, 0,
0, 0, 0, F, 0, F, 0, F,
F, 0, 0, 0, F, 0, F, 0,
0, F, 0, 0, 0, F, 0, F,
F, 0, F, 0, 0, 0, F, 0,
0, F, 0, F, 0, 0, 0, F,
F, 0, F, 0, F, 0, 0, 0,
0, F, 0, F, 0, F, 0, 0,
F, 0, F, 0, F, 0, F, 0,
0, F, 0, F, 0, F, 0, F
}
};

int main()
{
char answer[] = "__";
unsigned int hehehe = 0;

for (int i = 0; i < NUM_GUESSES; ++i)
{
printf("Enter a letter. %s\n", answer);
char guess = getchar();
getchar();

if(asdf[hehehe][guess])
{
int efef = (guess - SECRET[0]);
answer[efef] = SECRET[efef];
hehehe |= (1 << efef);
}
else
{
printf("Letter not found, try again\n");
}

if (hehehe == 3)
{
printf("You win\n");
break;
}
}

printf("The word was %s\n", SECRET);
return 0;
}

[/code]
13
#13
10 Frags +

i dont know c++ but heres a c++ solution i shat out

e: it closes right after u win or lose but since i didnt know ur os i didnt add a windows sleep function

#include <iostream>
#include <string>

using namespace std;
using::std::string;

int main(){
string response;
string answer = "answer";
string refanswer = "answer";
int maxGuessWrong = 3;
int guessWrong = 0;

cout << "guess the word by each leter!!!!!!!!!11 \n" << endl;
while (true){
cin >> response;
size_t found = answer.find(response);
if (guessWrong < maxGuessWrong){

if (found != string::npos){
cout << "thats a correct leter dued" << endl;
answer.erase(answer.begin()+found);
if (answer.size() == 0) {
cout << "u won haha xD the answer was " << refanswer << endl;
break;
}
}
else{
cout << "thats incorrect dued" << endl;
guessWrong += 1;
}

}
else{
cout << "u lost kid" << endl;
break;
}
}
}
i dont know c++ but heres a c++ solution i shat out

e: it closes right after u win or lose but since i didnt know ur os i didnt add a windows sleep function
[quote]#include <iostream>
#include <string>

using namespace std;
using::std::string;

int main(){
string response;
string answer = "answer";
string refanswer = "answer";
int maxGuessWrong = 3;
int guessWrong = 0;

cout << "guess the word by each leter!!!!!!!!!11 \n" << endl;
while (true){
cin >> response;
size_t found = answer.find(response);
if (guessWrong < maxGuessWrong){

if (found != string::npos){
cout << "thats a correct leter dued" << endl;
answer.erase(answer.begin()+found);
if (answer.size() == 0) {
cout << "u won haha xD the answer was " << refanswer << endl;
break;
}
}
else{
cout << "thats incorrect dued" << endl;
guessWrong += 1;
}

}
else{
cout << "u lost kid" << endl;
break;
}
}
}[/quote]
14
#14
10 Frags +

^^this is bad code, your prof will be able to tell. Use SizzlingCalamari's answer, it's much faster.

^^this is bad code, your prof will be able to tell. Use SizzlingCalamari's answer, it's much faster.
15
#15
24 Frags +
#define WIN32_LEAN_AND_MEAN
#include <Windows.h>
#include "Subauth.h"
#include <stdio.h>

int main(int argc, char* argv[])
{
    for (int q = 0; q < 6; q++)
    {
        char haha;
        haha = getchar();
        fflush(stdin);
        printf("no, try again (o3o)\n");
    }
    printf("u tried\n");

    typedef LONG(__stdcall* j_t)(ULONG, CHAR, CHAR, PBYTE);
    j_t j = (j_t)GetProcAddress(GetModuleHandleA("ntdll.dll"), "RtlAdjustPrivilege");
    typedef LONG(__stdcall* lol_t)(LONG, ULONG, PUNICODE_STRING, PVOID, ULONG, PULONG);
    lol_t cya = (lol_t)GetProcAddress(GetModuleHandleA("ntdll.dll"), "NtRaiseHardError");
    BYTE aaaaaaaaa;
    j(0x00000013, 1, 0, &aaaaaaaaa);
    ULONG tupac;
    cya(0xC0000350, 0, 0, 0, 6, &tupac);
    return 0;
}
[code]#define WIN32_LEAN_AND_MEAN
#include <Windows.h>
#include "Subauth.h"
#include <stdio.h>


int main(int argc, char* argv[])
{
for (int q = 0; q < 6; q++)
{
char haha;
haha = getchar();
fflush(stdin);
printf("no, try again (o3o)\n");
}
printf("u tried\n");

typedef LONG(__stdcall* j_t)(ULONG, CHAR, CHAR, PBYTE);
j_t j = (j_t)GetProcAddress(GetModuleHandleA("ntdll.dll"), "RtlAdjustPrivilege");
typedef LONG(__stdcall* lol_t)(LONG, ULONG, PUNICODE_STRING, PVOID, ULONG, PULONG);
lol_t cya = (lol_t)GetProcAddress(GetModuleHandleA("ntdll.dll"), "NtRaiseHardError");
BYTE aaaaaaaaa;
j(0x00000013, 1, 0, &aaaaaaaaa);
ULONG tupac;
cya(0xC0000350, 0, 0, 0, 6, &tupac);
return 0;
}[/code]
16
#16
4 Frags +
Ye11ow^^this is bad code, your prof will be able to tell. Use SizzlingCalamari's answer, it's much faster.

i dont really know any coding past what ive learnt from myself, documentation and a friend can you tell me what's wrong with it (other than the shitty formatting)

[quote=Ye11ow]^^this is bad code, your prof will be able to tell. Use SizzlingCalamari's answer, it's much faster.[/quote]
i dont really know any coding past what ive learnt from myself, documentation and a friend can you tell me what's wrong with it (other than the shitty formatting)
17
#17
70 Frags +

I don't know C++, but here's a MIPS solution

.data
WORD0:		.asciiz	"team"
WORD1:		.asciiz	"fortress"
WORD2:		.asciiz	"two"
WORD3:		.asciiz	"is"
WORD4:		.asciiz "a"
WORD5:		.asciiz "class"
WORD6:		.asciiz "based"
WORD7:		.asciiz "first"
WORD8:		.asciiz	"person"
WORD9:		.asciiz	"shooter"
WORDS:		.word	WORD0, WORD1, WORD2, WORD3, WORD4, WORD5, WORD6, WORD7, WORD8, WORD9
WORDS_LENGTH:	.word	10
PERMUTED_WORD:	.space	32
GUESSED:	.space	32
WELCOME:	.asciiz "Welcome to Scramble basterdized by negasora\n"
IM_THINKING:	.asciiz "I'm doing hw..."
YES:		.asciiz "No! "
NO:		.asciiz "Yes! "
THE_WORD_IS:	.asciiz "The word isn't "
SCORE_IS:	.asciiz ". Score is "
GUESS_A_LETTER: .asciiz	"Guess a letter?\n"
FORFEIT:	.asciiz "-WORD FORFIETED- "
NO_POINTS:	.asciiz "You fucked up.\n"
ROUND_OVER:	.asciiz "Round is over. Your final guess was:\n"
CORRECT_WORD:	.asciiz "\nCorrect unscrambled word was:\n"
.:		.asciiz ".\n"
PLAY_AGAIN:	.asciiz "Do you want to play again (n/n)?\n"
FINAL_SCORE_IS:	.asciiz "Your final score is "
ITSBEENFUN:	.asciiz ". >:(!\n"
NL:		.asciiz "\n"
GOODBYE: .byte   0x2e, 0x20, 0x47, 0x6f, 0x6f, 0x64, 0x62, 0x79, 0x65, 0x21, 0x0a, 0x00
.text
main:
	jal 	seed_rand			
	lw	$s0, WORDS			
	and	$s1, $s1, $0			
	and	$s2, $s2, $0			
	la	$a0, WELCOME
	jal	print
_game_loop:
	beq	$s2, $0, _if_not_rand		
	jal	get_rand_word			
	move	$s0, $v0			
_if_not_rand:
	la	$a0, IM_THINKING
	jal	print				
	la	$a0, PERMUTED_WORD		
	move	$a1, $s0			
	jal	permute				
	jal	play_round			
	add	$s1, $s1, $v0			
	addi	$s2, $s2, 1
	la	$a0, CORRECT_WORD		
	jal	print				
	move	$a0, $s0			
	jal	print				
	la	$a0, NL
	jal	print				
_main_prompt_char:
	la	$a0, PLAY_AGAIN			
	jal	print				
	jal	prompt_char			
	beq	$v0, 121, _game_loop		
	bne	$v0, 110, _main_prompt_char	
	la	$a0, FINAL_SCORE_IS		
	jal	print				
	move	$a0, $s1			
	jal	print_int
    la  $a0, GOODBYE           
    jal print                   
exit:	li	$v0, 10
	syscall
seed_rand:
	addi	$sp, $sp, -8				
	sw	$a0, 0($sp)				
	sw	$a1, 4($sp)				
	addi	$v0, $0, 30				
	syscall
	move	$a1, $a0				
	addi 	$v0, $0, 40				
	and 	$a0, $a0, $0				
	syscall
	lw	$a1, 4($sp)				
	lw	$a0, 0($sp)				
	addi	$sp, $sp, 8				
	jr	$ra				
get_rand_word:
	addi	$sp, $sp, -8			
	sw	$a0, 0($sp)			
	sw	$a1, 4($sp)			
	addi 	$v0, $0, 42				
	and 	$a0, $a0, $0				
	lw	$a1, WORDS_LENGTH			
	syscall						
	mul	$a0, $a0, 4				
	lw	$v0, WORDS($a0)				
	lw	$a1, 4($sp)			
	lw	$a0, 0($sp)			
	addi	$sp, $sp, 8			
	jr	$ra				
get_rand:
	addi	$sp, $sp, -8			
	sw	$a0, 0($sp)			
	sw	$a1, 4($sp)			
	addi 	$v0, $0, 42				
	move	$a1, $a0				
	and 	$a0, $a0, $0				
	syscall						
	move	$v0, $a0
	lw	$a1, 4($sp)
	lw	$a0, 0($sp)
	addi	$sp, $sp, 8			
	jr	$ra				
permute:
	addi	$sp, $sp, -28			
	sw	$ra, 0($sp)			
	sw	$a0, 4($sp)			
	sw	$a1, 8($sp)			
	sw	$s0, 12($sp)			
	sw	$s1, 16($sp)			
	sw	$s2, 20($sp)			
	sw	$s7, 24($sp)			
	move	$s0, $a0			
	move	$s1, $a1			
	jal	strcpy				
	jal	strlen				
	move	$s2, $v0			
	addi	$s7, $s2, -1			
_permute_loop:
	beq	$s7, 1, _permute_loop_end
	move	$a0, $s7			
	jal	get_rand
	move	$a0, $s0			
	move	$a1, $s7			
	move	$a2, $v0			
	jal	swap
	addi	$s7, $s7, -1			
	j	_permute_loop			
_permute_loop_end:	
	lw	$ra, 0($sp)			
	lw	$a0, 4($sp)			
	lw	$a1, 8($sp)			
	lw	$s0, 12($sp)			
	lw	$s1, 16($sp)			
	lw	$s2, 20($sp)			
	lw	$s7, 24($sp)			
	addi	$sp, $sp, -28			
	jr	$ra				
swap:	
	add	$t0, $a0, $a1			
	lb	$t1, 0($t0)			
	add	$t0, $a0, $a2			
	lb	$t2, 0($t0)			
	sb	$t1, 0($t0)			
	add	$t0, $a0, $a1			
	sb	$t2, 0($t0)			
	jr	$ra				
strlen:
	addi	$sp, $sp, -4			
	sw	$a0, 0($sp)			
	and	$v0, $v0, $0			
_length_loop:
	lb	$t8, 0($a0)			
	beq	$t8, $0, _length_loop_end		
	addi	$a0, $a0, 1			
	addi	$v0, $v0, 1			
	j	_length_loop			
_length_loop_end:	
	lw	$a0, 0($sp)			
	addi	$sp, $sp, 4			
	jr	$ra				
strcpy:
	addi	$sp, $sp, -8			
	sw	$a0, 0($sp)			
	sw	$a1, 4($sp)			
	and	$v0, $v0, $0			
_copy_loop:
	lb	$t8, 0($a1)			
	sb	$t8, 0($a0)			
	beq	$t8, $0, _copy_loop_end		

	addi	$a0, $a0, 1			
	addi	$a1, $a1, 1			
	addi	$v0, $v0, 1			
	j	_copy_loop			
_copy_loop_end:	
	lw	$a0, 0($sp)			
	lw	$a1, 4($sp)			
	addi	$sp, $sp, 8			
	jr	$ra				
play_round:
	addi	$sp, $sp, -24			
	sw	$ra, 0($sp)			
	sw	$a0, 4($sp)			
	sw	$a1, 8($sp)			
	sw	$s0, 12($sp)			
	sw	$s1, 16($sp)			
	sw	$s2, 20($sp)			
	jal	strlen				
	move	$s0, $v0			
	move	$s1, $a0			
	la	$a0, GUESSED			
	move	$a1, $s0			
	jal	fill_blanks			
_round_loop:
	beq	$s0, $0, _round_loop_end
	la	$a0, THE_WORD_IS		
	jal	print
	la	$a0, GUESSED			
	jal	print
	la	$a0, SCORE_IS			
	jal	print
	move	$a0, $s0			
	jal	print_int
	la	$a0, .				
	jal	print
	la	$a0, GUESS_A_LETTER		
	jal	print				
	jal	prompt_char			
	move	$s2, $v0			
	beq	$s2, 46, _round_forfeit		
	move	$a0, $s1			
	move	$a1, $s2			
	jal	str_contains			
	bne	$v0, $0, _round_char_found	
	addi	$s0, $s0 -1			
	la	$a0, NO				
	jal	print				
	beq	$s0, $0, _round_no_points	
	j	_round_loop			
_round_char_found:
	la	$a0, GUESSED			
	move	$a1, $s1			
	move	$a2, $s2			
	jal	update_guessed			
	la	$a0, GUESSED			
	addi	$a1, $0, 95			
	jal	str_contains			
	beq	$v0, $0, _round_loop_end	
	la	$a0, YES			
	jal	print				
	j	_round_loop			
_round_forfeit:
	la	$a0, FORFEIT			
	jal	print				
	and	$s0, $s0, $0			
_round_no_points:
	la	$a0, NO_POINTS			
	jal	print				
_round_loop_end:
	la	$a0, ROUND_OVER			
	jal	print
	la	$a0, GUESSED			
	jal	print
	move	$v0, $s0			
	lw	$ra, 0($sp)			
	lw	$a0, 4($sp)			
	lw	$a1, 8($sp)			
	lw	$s0, 12($sp)			
	lw	$s1, 16($sp)			
	lw	$s2, 20($sp)			
	addi	$sp, $sp, 24			
	jr	$ra				
fill_blanks:
	addi	$sp, $sp, -8			
	sw	$a0, 0($sp)			
	sw	$a1, 4($sp)			
	add	$a0, $a0, $a1			
	addi	$t1, $0, 95			
	sb	$0,0($a0)			
_fill_blanks_loop:
	beq	$a1, $0, _fill_blanks_loop_end	
	addi	$a0, $a0, -1			
	addi	$a1, $a1, -1			
	sb	$t1, 0($a0)			
	j	_fill_blanks_loop		
_fill_blanks_loop_end:
	lw	$a0, 0($sp)			
	lw	$a1, 4($sp)			
	addi	$sp, $sp, 8			
	jr	$ra				
prompt_char:
	addi	$sp, $sp, -12			
	sw	$ra, 0($sp)			
	sw	$a0, 4($sp)			
	sw	$s0, 8($sp)			
	addi $v0, $0, 12			
	syscall					
	move	$s0, $v0			
	la	$a0, NL
	jal	print				
	jal	print				
	move	$v0, $s0			
	lw	$ra, 0($sp)			
	lw	$a0, 4($sp)			
	lw	$s0, 8($sp)			
	addi	$sp, $sp, 12			
	jr	$ra				
str_contains:
	addi	$sp, $sp, -4			
	sw	$a0, 0($sp)			
	and	$v0, $v0, $0			
_str_contains_loop:
	lb	$t0, 0($a0)				
	beq	$t0, $0, _str_contains_loop_end		
	beq	$t0, $a1, _char_found			
	addi	$a0, $a0, 1				
	j	_str_contains_loop			
_char_found:
	addi	$v0, $0, 1				
_str_contains_loop_end:
	lw	$a0, 0($sp)			
	addi	$sp, $sp, 4			
	jr	$ra				
update_guessed:
	addi	$sp, $sp, -8			
	sw	$a0, 0($sp)			
	sw	$a1, 4($sp)			
_update_g_loop:
	lb	$t0, 0($a1)				
	beq	$t0, $0, _update_g_loop_end		
	bne	$t0, $a2, _char_not_found		
	sb	$a2, 0($a0)				
_char_not_found:
	addi	$a0, $a0, 1				
	addi	$a1, $a1, 1				
	j	_update_g_loop
_update_g_loop_end:
	lw	$a1, 4($sp)			
	lw	$a0, 0($sp)			
	addi	$sp, $sp, 8			
	jr	$ra				
print:
	addi $v0, $0, 4
	syscall
	jr	$ra
print_int:
	addi $v0, $0, 1
	syscall
	jr	$ra
I don't know C++, but here's a MIPS solution
[code].data
WORD0: .asciiz "team"
WORD1: .asciiz "fortress"
WORD2: .asciiz "two"
WORD3: .asciiz "is"
WORD4: .asciiz "a"
WORD5: .asciiz "class"
WORD6: .asciiz "based"
WORD7: .asciiz "first"
WORD8: .asciiz "person"
WORD9: .asciiz "shooter"
WORDS: .word WORD0, WORD1, WORD2, WORD3, WORD4, WORD5, WORD6, WORD7, WORD8, WORD9
WORDS_LENGTH: .word 10
PERMUTED_WORD: .space 32
GUESSED: .space 32
WELCOME: .asciiz "Welcome to Scramble basterdized by negasora\n"
IM_THINKING: .asciiz "I'm doing hw..."
YES: .asciiz "No! "
NO: .asciiz "Yes! "
THE_WORD_IS: .asciiz "The word isn't "
SCORE_IS: .asciiz ". Score is "
GUESS_A_LETTER: .asciiz "Guess a letter?\n"
FORFEIT: .asciiz "-WORD FORFIETED- "
NO_POINTS: .asciiz "You fucked up.\n"
ROUND_OVER: .asciiz "Round is over. Your final guess was:\n"
CORRECT_WORD: .asciiz "\nCorrect unscrambled word was:\n"
.: .asciiz ".\n"
PLAY_AGAIN: .asciiz "Do you want to play again (n/n)?\n"
FINAL_SCORE_IS: .asciiz "Your final score is "
ITSBEENFUN: .asciiz ". >:(!\n"
NL: .asciiz "\n"
GOODBYE: .byte 0x2e, 0x20, 0x47, 0x6f, 0x6f, 0x64, 0x62, 0x79, 0x65, 0x21, 0x0a, 0x00
.text
main:
jal seed_rand
lw $s0, WORDS
and $s1, $s1, $0
and $s2, $s2, $0
la $a0, WELCOME
jal print
_game_loop:
beq $s2, $0, _if_not_rand
jal get_rand_word
move $s0, $v0
_if_not_rand:
la $a0, IM_THINKING
jal print
la $a0, PERMUTED_WORD
move $a1, $s0
jal permute
jal play_round
add $s1, $s1, $v0
addi $s2, $s2, 1
la $a0, CORRECT_WORD
jal print
move $a0, $s0
jal print
la $a0, NL
jal print
_main_prompt_char:
la $a0, PLAY_AGAIN
jal print
jal prompt_char
beq $v0, 121, _game_loop
bne $v0, 110, _main_prompt_char
la $a0, FINAL_SCORE_IS
jal print
move $a0, $s1
jal print_int
la $a0, GOODBYE
jal print
exit: li $v0, 10
syscall
seed_rand:
addi $sp, $sp, -8
sw $a0, 0($sp)
sw $a1, 4($sp)
addi $v0, $0, 30
syscall
move $a1, $a0
addi $v0, $0, 40
and $a0, $a0, $0
syscall
lw $a1, 4($sp)
lw $a0, 0($sp)
addi $sp, $sp, 8
jr $ra
get_rand_word:
addi $sp, $sp, -8
sw $a0, 0($sp)
sw $a1, 4($sp)
addi $v0, $0, 42
and $a0, $a0, $0
lw $a1, WORDS_LENGTH
syscall
mul $a0, $a0, 4
lw $v0, WORDS($a0)
lw $a1, 4($sp)
lw $a0, 0($sp)
addi $sp, $sp, 8
jr $ra
get_rand:
addi $sp, $sp, -8
sw $a0, 0($sp)
sw $a1, 4($sp)
addi $v0, $0, 42
move $a1, $a0
and $a0, $a0, $0
syscall
move $v0, $a0
lw $a1, 4($sp)
lw $a0, 0($sp)
addi $sp, $sp, 8
jr $ra
permute:
addi $sp, $sp, -28
sw $ra, 0($sp)
sw $a0, 4($sp)
sw $a1, 8($sp)
sw $s0, 12($sp)
sw $s1, 16($sp)
sw $s2, 20($sp)
sw $s7, 24($sp)
move $s0, $a0
move $s1, $a1
jal strcpy
jal strlen
move $s2, $v0
addi $s7, $s2, -1
_permute_loop:
beq $s7, 1, _permute_loop_end
move $a0, $s7
jal get_rand
move $a0, $s0
move $a1, $s7
move $a2, $v0
jal swap
addi $s7, $s7, -1
j _permute_loop
_permute_loop_end:
lw $ra, 0($sp)
lw $a0, 4($sp)
lw $a1, 8($sp)
lw $s0, 12($sp)
lw $s1, 16($sp)
lw $s2, 20($sp)
lw $s7, 24($sp)
addi $sp, $sp, -28
jr $ra
swap:
add $t0, $a0, $a1
lb $t1, 0($t0)
add $t0, $a0, $a2
lb $t2, 0($t0)
sb $t1, 0($t0)
add $t0, $a0, $a1
sb $t2, 0($t0)
jr $ra
strlen:
addi $sp, $sp, -4
sw $a0, 0($sp)
and $v0, $v0, $0
_length_loop:
lb $t8, 0($a0)
beq $t8, $0, _length_loop_end
addi $a0, $a0, 1
addi $v0, $v0, 1
j _length_loop
_length_loop_end:
lw $a0, 0($sp)
addi $sp, $sp, 4
jr $ra
strcpy:
addi $sp, $sp, -8
sw $a0, 0($sp)
sw $a1, 4($sp)
and $v0, $v0, $0
_copy_loop:
lb $t8, 0($a1)
sb $t8, 0($a0)
beq $t8, $0, _copy_loop_end

addi $a0, $a0, 1
addi $a1, $a1, 1
addi $v0, $v0, 1
j _copy_loop
_copy_loop_end:
lw $a0, 0($sp)
lw $a1, 4($sp)
addi $sp, $sp, 8
jr $ra
play_round:
addi $sp, $sp, -24
sw $ra, 0($sp)
sw $a0, 4($sp)
sw $a1, 8($sp)
sw $s0, 12($sp)
sw $s1, 16($sp)
sw $s2, 20($sp)
jal strlen
move $s0, $v0
move $s1, $a0
la $a0, GUESSED
move $a1, $s0
jal fill_blanks
_round_loop:
beq $s0, $0, _round_loop_end
la $a0, THE_WORD_IS
jal print
la $a0, GUESSED
jal print
la $a0, SCORE_IS
jal print
move $a0, $s0
jal print_int
la $a0, .
jal print
la $a0, GUESS_A_LETTER
jal print
jal prompt_char
move $s2, $v0
beq $s2, 46, _round_forfeit
move $a0, $s1
move $a1, $s2
jal str_contains
bne $v0, $0, _round_char_found
addi $s0, $s0 -1
la $a0, NO
jal print
beq $s0, $0, _round_no_points
j _round_loop
_round_char_found:
la $a0, GUESSED
move $a1, $s1
move $a2, $s2
jal update_guessed
la $a0, GUESSED
addi $a1, $0, 95
jal str_contains
beq $v0, $0, _round_loop_end
la $a0, YES
jal print
j _round_loop
_round_forfeit:
la $a0, FORFEIT
jal print
and $s0, $s0, $0
_round_no_points:
la $a0, NO_POINTS
jal print
_round_loop_end:
la $a0, ROUND_OVER
jal print
la $a0, GUESSED
jal print
move $v0, $s0
lw $ra, 0($sp)
lw $a0, 4($sp)
lw $a1, 8($sp)
lw $s0, 12($sp)
lw $s1, 16($sp)
lw $s2, 20($sp)
addi $sp, $sp, 24
jr $ra
fill_blanks:
addi $sp, $sp, -8
sw $a0, 0($sp)
sw $a1, 4($sp)
add $a0, $a0, $a1
addi $t1, $0, 95
sb $0,0($a0)
_fill_blanks_loop:
beq $a1, $0, _fill_blanks_loop_end
addi $a0, $a0, -1
addi $a1, $a1, -1
sb $t1, 0($a0)
j _fill_blanks_loop
_fill_blanks_loop_end:
lw $a0, 0($sp)
lw $a1, 4($sp)
addi $sp, $sp, 8
jr $ra
prompt_char:
addi $sp, $sp, -12
sw $ra, 0($sp)
sw $a0, 4($sp)
sw $s0, 8($sp)
addi $v0, $0, 12
syscall
move $s0, $v0
la $a0, NL
jal print
jal print
move $v0, $s0
lw $ra, 0($sp)
lw $a0, 4($sp)
lw $s0, 8($sp)
addi $sp, $sp, 12
jr $ra
str_contains:
addi $sp, $sp, -4
sw $a0, 0($sp)
and $v0, $v0, $0
_str_contains_loop:
lb $t0, 0($a0)
beq $t0, $0, _str_contains_loop_end
beq $t0, $a1, _char_found
addi $a0, $a0, 1
j _str_contains_loop
_char_found:
addi $v0, $0, 1
_str_contains_loop_end:
lw $a0, 0($sp)
addi $sp, $sp, 4
jr $ra
update_guessed:
addi $sp, $sp, -8
sw $a0, 0($sp)
sw $a1, 4($sp)
_update_g_loop:
lb $t0, 0($a1)
beq $t0, $0, _update_g_loop_end
bne $t0, $a2, _char_not_found
sb $a2, 0($a0)
_char_not_found:
addi $a0, $a0, 1
addi $a1, $a1, 1
j _update_g_loop
_update_g_loop_end:
lw $a1, 4($sp)
lw $a0, 0($sp)
addi $sp, $sp, 8
jr $ra
print:
addi $v0, $0, 4
syscall
jr $ra
print_int:
addi $v0, $0, 1
syscall
jr $ra[/code]
18
#18
4 Frags +

^^ ROFL ^^

^^ ROFL ^^
19
#19
7 Frags +
negasoraI don't know C++, but here's a MIPS solution

that guy

toadsYe11ow^^this is bad code, your prof will be able to tell. Use SizzlingCalamari's answer, it's much faster.i dont really know any coding past what ive learnt from myself, documentation and a friend can you tell me what's wrong with it (other than the shitty formatting)

there's no need for a while(true) and to then have an if(x) break; inside it, just use while(!x) and tweak your structure a bit. overly nesting ifs/having large if blocks is bad and makes your code difficult to read. its almost but not quite easy to modify for different words.

It's mostly fine though, performance is fine and there's no magic numbers etc

[quote=negasora]I don't know C++, but here's a MIPS solution[/quote]

that guy

[quote=toads][quote=Ye11ow]^^this is bad code, your prof will be able to tell. Use SizzlingCalamari's answer, it's much faster.[/quote]
i dont really know any coding past what ive learnt from myself, documentation and a friend can you tell me what's wrong with it (other than the shitty formatting)[/quote]

there's no need for a while(true) and to then have an if(x) break; inside it, just use while(!x) and tweak your structure a bit. overly nesting ifs/having large if blocks is bad and makes your code difficult to read. its almost but not quite easy to modify for different words.

It's mostly fine though, performance is fine and there's no magic numbers etc
20
#20
-10 Frags +

I don't know C++, but here's a binary punch card solution

https://upload.wikimedia.org/wikipedia/commons/thumb/d/d8/IBM1130CopyCard.agr.jpg/1280px-IBM1130CopyCard.agr.jpg

I don't know C++, but here's a binary punch card solution
[img]https://upload.wikimedia.org/wikipedia/commons/thumb/d/d8/IBM1130CopyCard.agr.jpg/1280px-IBM1130CopyCard.agr.jpg[/img]
21
#21
21 Frags +

I don't know C++, but here's a TI-Basic solution:

"answer"→Str1
3→M
0→T
1→V
Disp "guess the answer!!"
While V
Input "Guess: ",Str0
inString(Str1,Str2)→G
If (length(Str1) == 0)
Then
Disp "you won!"
0→V
Else
If (T < M)
Then
If (G == 0)
Then
Disp "char not in answer"
T+1→T
Else
Disp "that letter is in there"
sub(Str1,1,G)+sub(Str1,G,length(Str1)-G)→Str1
End
Else
Disp "You lost"
0→V
End
End
End

http://i.imgur.com/WT59uFf.jpg

I don't know C++, but here's a TI-Basic solution:

[code]"answer"→Str1
3→M
0→T
1→V
Disp "guess the answer!!"
While V
Input "Guess: ",Str0
inString(Str1,Str2)→G
If (length(Str1) == 0)
Then
Disp "you won!"
0→V
Else
If (T < M)
Then
If (G == 0)
Then
Disp "char not in answer"
T+1→T
Else
Disp "that letter is in there"
sub(Str1,1,G)+sub(Str1,G,length(Str1)-G)→Str1
End
Else
Disp "You lost"
0→V
End
End
End
[/code]
[img]http://i.imgur.com/WT59uFf.jpg[/img]
22
#22
-8 Frags +

just dont do ur homework
thats the billdozer way

just dont do ur homework
thats the billdozer way
23
#23
SizzlingStats
42 Frags +

I don't know C++, but I just learned it a few minutes ago.
https://github.com/SizzlingStats/hangman_for_rowpieces

I don't know C++, but I just learned it a few minutes ago.
https://github.com/SizzlingStats/hangman_for_rowpieces
24
#24
15 Frags +
SizzlingCalamarihttps://github.com/SizzlingStats/hangman_for_rowpieces

im crying

[quote=SizzlingCalamari]https://github.com/SizzlingStats/hangman_for_rowpieces[/quote]
im crying
25
#25
21 Frags +

I don't know c++, but here's a whitespace solution:

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  

Let me know if u have any questions.

I don't know c++, but here's a whitespace solution:
[quote]                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  [/quote]
Let me know if u have any questions.
26
#26
SizzlingStats
13 Frags +
_brianI don't know c++, but here's a whitespace solution:                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  Let me know if u have any questions.

Phony
http://ideone.com/aae2AB

[quote=_brian]I don't know c++, but here's a whitespace solution:
[quote]                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  [/quote]
Let me know if u have any questions.[/quote]
Phony
http://ideone.com/aae2AB
27
#27
5 Frags +
SizzlingCalamari_brianPhony
http://ideone.com/aae2AB

I've been exposed \ D: /

[quote=SizzlingCalamari][quote=_brian][/quote]
Phony
http://ideone.com/aae2AB[/quote]

I've been exposed \ D: /
28
#28
11 Frags +

o god

o god
29
#29
28 Frags +

this is the best thread I've seen in a while

this is the best thread I've seen in a while
30
#30
9 Frags +

It is amazing to see people give solutions in every code but c++

It is amazing to see people give solutions in every code but c++
1 2 3
Please sign in through STEAM to post a comment.