#include <iostream>
#include <ctime>
#include <string>
int main()
{
usingnamespace std;
srand(time(NULL));
shortint iScore;
shortint eScore;
iScore=0;//your score
eScore=0;//opponent score
shortint iType;
shortint eType;
double rundor;//amount of rounds
string stensaxpase;
cout<<" *************************\n";
cout<<" * Sten Sax Pase *\n";
cout<<" *************************\n";//"header"
cout<<endl;
cout<<endl;
cout<<endl;
cout<<endl;
cout<<endl;
cout<<"Hur manga rundor?\n";//how many rounds?
cin>>rundor;
while (iScore<=rundor && eScore<=rundor);
{
eType = rand() / (RAND_MAX / 3 + 1) + 1;
cout << "Sten sax eller pase?(1=sten,2=sax,3=pase)\n";
cin>>stensaxpase;
if ('stensaxpase' == 'sten'||'stensaxpase' == 'Sten');
{
iType=1;
}
elseif ('stensaxpase' == 'sax'||'stensaxpase' == 'Sax');
/* /\/\/\
problem!("[Warning] character constant too long for its type")
*/
{
iType=2;
}
elseif (stensaxpase == "Pase" || stensaxpase == "pase")
{
itype=3;
}
if (iType == 1);
{
if (eType =1);//sten
{
cout<< "Lika!";
}
elseif (eType =2);//sax
{
cout<<"Du vann rundan!";
iScore=iScore+1;
cout<<"Du har "<< iScore<<"poang och motstandaren har "<<eScore;
}
if (eType =3);//påse
{
cout<< "Du forlorade rundan!;
eScore=eScore+1;
cout<<"Du har "<< iScore<<"poang och motstandaren har "<<eScore;
}
else
{
cout<< "Skriv antingen sten, sax eller pase(med ring över)";
}
}
else if (iType == 2);
{
}
else if(iType == 3);
{
}
else;
{
cout<<"Skriv 1 for sten, 2 för sax eller 3 för pase!";
}
}
cin.ignore();
cin.get();
}
the else if (text)is the same as the if one... i can't figure out whats wrong, although ive been coding for 3-4 days.
Anyone who is more experienced?
It's a rock paper scissors game.
rock=sten in code paper=påse(or pase) and scissor=sax
(BTW first time in any forum for me, so tell me if i did something wrong ;P)
1) You need to use double quotes (") for string literals. Single quotes (') are for character literals.
2) Remove the semicolon at the end of the line. That terminates the then portion of the if statement.