#this shows me the same s as i first entered it,how can i change?

15 messages · Page 1 of 1 (latest)

stoic lava
#

#include <iostream>
#include <ctime>
#include <cstdlib>
using namespace std;
int main()
{
int n,i,s,p,g,x;
string nume;
string rasp;
string rasp2;
string rasp3;
cout<<"Introdu suma"<<endl;
cin>>s;
do
{
cout<<"Buna ziua!Cum va numiti?"<<endl;
cin.ignore();
getline(cin,nume);
cout<<nume<<" cat vrei sa pariezi?"<<endl;
cin>>p;
cout<<"Cat de mare vrei sa fie nr maxim generat?"<<endl;
cin>>g;
x=g/100;
cout<<"Vrei ca nr tau sa fie aproape de nr generat?"<<endl;
cin.ignore();
getline(cin,rasp2);
if(rasp2=="Nu")
{
srand(time(0));
n=rand()%g+1;
cin>>i;
if(i==n)
{
s=s+pgx;
cout<<s<<endl;
}
else if(i!=n)
{
s=s-p;
cout<<s<<endl;
}
}
else if(rasp2=="Da")
{
float nr,pp;
cout<<"Cat de aproape vrei ca nr tau sa fie de nr generat?"<<endl;
cin>>nr;
pp=100/nr;
srand(time(0));
n=rand()%g+1;
cin>>i;
if(i>=n-5 && i<=n+5)
{
s=s+pgpp*x;
cout<<s<<endl;
}
else if(i<n-5 || i>n+5)
{
s=s-p;
cout<<s<<endl;
}
}
cout<<"Mai joci?";
cin.ignore();
getline(cin,rasp3);
}
while(rasp3=="Da");
return 0;
}

sick sapphireBOT
#

When your question is answered use !solved to mark the question as resolved.

Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question use !howto ask.

humble trout
#
#include <iostream>
#include <ctime>
#include <cstdlib>
using namespace std;
int main()
{
    int n,i,s,p,g,x;
    string nume;
    string rasp;
    string rasp2;
    string rasp3;
    cout<<"Introdu suma"<<endl;
    cin>>s;
    do
    {
    cout<<"Buna ziua!Cum va numiti?"<<endl;
    cin.ignore();
    getline(cin,nume);
    cout<<nume<<" cat vrei sa pariezi?"<<endl;
    cin>>p;
    cout<<"Cat de mare vrei sa fie nr maxim generat?"<<endl;
    cin>>g;
    x=g/100;
    cout<<"Vrei ca nr tau sa fie aproape de nr generat?"<<endl;
    cin.ignore();
    getline(cin,rasp2);
    if(rasp2=="Nu")
    {
      srand(time(0));
      n=rand()%g+1;
      cin>>i;
      if(i==n)
      {
          s=s+pgx;
          cout<<s<<endl;
      }
      else if(i!=n)
      {
          s=s-p;
          cout<<s<<endl;
      }
    }
    else if(rasp2=="Da")
    {
        float nr,pp;
        cout<<"Cat de aproape vrei ca nr tau sa fie de nr generat?"<<endl;
        cin>>nr;
        pp=100/nr;
        srand(time(0));
        n=rand()%g+1;
        cin>>i;
        if(i>=n-5 && i<=n+5)
        {
            s=s+pgpp*x;
            cout<<s<<endl;
        }
        else if(i<n-5 || i>n+5)
        {
            s=s-p;
            cout<<s<<endl;
        }
    }
    cout<<"Mai joci?";
    cin.ignore();
    getline(cin,rasp3);
    }
    while(rasp3=="Da");
    return 0;
}
#

please wrap your code in ```cpp

#

for highlighting

#

@stoic lava this code is invalid

#

s = s + pgx;

#

pgx is never defined

#

also you never included #include <string>?

#

you need that

#

s = s + pgpp * x;

#

you never defined pgpp either

#

if you want to add all those variables on, you'd need to do s = s + p + g + x

stoic lava
#

hey!sorry,the code didnt copy right,i meant s=s+p* g * x and s=s+ p * g * pp *x

#

oh,i found my mistake,thanks for trying to help me!