Is it just my noobiness, or is this code just WRONG?

Started by
3 comments, last by Storyyeller 14 years, 1 month ago
Am i mistaken? when i looked at this code i was like WTF

#include<iostream.h>
#include<conio.h>

void box(int x, int xx, int y, int yy);
void box(int x, int xx, int y, int yy)
{
int xs,ys,i,j;
xs=xx-x;
ys=yy-y;
for(i=1; i<xs; i++){gotoxy(x+i,y);cout<<"Í";
gotoxy(x+i,yy);cout<<"Í"; }
for(j=1; j<ys; j++){gotoxy(x,y+j);cout<<"º"; }
for(j=1; j<ys; j++){gotoxy(xx,y+j);cout<<"º"; }
{gotoxy(x,y);cout<<"É";
gotoxy(x,yy);cout<<"È";
gotoxy(xx,y);cout<<"»";
gotoxy(xx,yy);cout<<"¼";}
}

char ans;
char ask;
int life;
int main()
{
clrscr();
box(5,50,1,45);
box(55,78,8,30);
gotoxy(62,12);cout<<"LIFELINE";
gotoxy(57,15);cout<<"1. 50:50";

gotoxy(57,18);cout<<"2. Call a friend";
gotoxy(57,21);cout<<"3. Ask the audience";

gotoxy(13,3);cout<<"Who Wants to be a Millionaire?";
gotoxy(10,5);cout<<"The Folder contains?";
gotoxy(10,9);cout<<"a. Foods";
gotoxy(24,9);cout<<"b. Files";
gotoxy(10,11);cout<<"c. Animals";
gotoxy(24,11);cout<<"d. Clothes";
getch();
gotoxy(9,13);cout<<"Do you want to use your lifeline?";
gotoxy(13,14);cout<<" Y/N : ";
cin>>ask;
if(ask=='y')
{
gotoxy(10,15);cout<<"Choose Lifeline Number: ";
cin>>life;
if(life==1)
{
gotoxy(18,17);cout<<"[ 50:50 ]";
gotoxy(10,19);cout<<"_________";
gotoxy(24,19);cout<<"c. Animals";
gotoxy(10,21);cout<<"b. Files";
gotoxy(24,21);cout<<"_________";
getch();
}
else if(life==2)
{
gotoxy(18,17);cout<<"[ Call a friend ]";
gotoxy(10,20);cout<<"Friend: I think it is B";
getch();
gotoxy(10,23);cout<<"You: How sure are you?";
getch();
gotoxy(10,26);cout<<"Friend: I'm 95% sure about this.";
getch();
}
else if(life==3)
{
gotoxy(18,17);cout<<"[ Ask the audience ]";
gotoxy(10,23);cout<<"(a.) 23% (b.) 52% (c.) 13% (d.) 12%";
getch();
}
}
else if(ask=='n')
getch();
gotoxy(10,30);cout<<"Your answer is: ";
cin>>ans;
if(ans=='a')
{
gotoxy(14,35);cout<<"Correct!";
gotoxy(10,38);cout<<"Get ready for the next round!";
}
else
{
gotoxy(14,35);cout<<"Wrong!";
gotoxy(10,38);cout<<"Play again?";
getch();
return 0;
} }

"Spending your life waiting for the messiah to come save the world is like waiting around for the straight piece to come in Tetris...even if it comes, by that time you've accumulated a mountain of shit so high that you're fucked no matter what you do. "
Advertisement
Me too.

Lack of indentation.

Use of prestandard <iostream.h> (<conio.h> isn't standard either.)

void box(int x, int xx, int y, int yy);void box(int x, int xx, int y, int yy){    ...}


WTF!

Hardcoding the question(s) and responses.
Not to mention the fact that all the life-lines lead towards the answer 'b', then the correct answer is actually 'a'.
I saw goto in there somewhere. Yes, the code is wrong.
C++: Where your friends have access to your private members
I don't think it's a real goto, just a function.
I trust exceptions about as far as I can throw them.

This topic is closed to new replies.

Advertisement