Home > Back-end >  Dear bosses, I use a custom function is always has a problem, can't find where is wrong again,
Dear bosses, I use a custom function is always has a problem, can't find where is wrong again,

Time:12-01

#include
#include
#include
Int Computer (int n);
Int main ()
{int x, y, m; Printf (" Input 1 or 1, 2: "); scanf("%d",& X); Y=Computer (x); For (m=x; m<=30; M++) {printf (" Input it continuing: "); scanf("%d",& X); } the if (Computer (y)==30) {printf (" You lose! \n"); } the else printf (" You win! \n");
}
Int Computer (int n)
{int e, r;/for the random number * * r/r=Rnd (); If ((e + 1) % 3==1) {printf (" % d ", e + 1); } else if ((e + 1) % 3==2) {printf (" \ n % d, % d ", e + 1, e + 2); } else if ((e + 1) % 3==0 & amp; & R % 2==0) {printf (" % d ", e + 1); } else if ((e + 1) % 3==0 & amp; & R % 2==1); {printf (" \ n % d, % d ", e + 1, e + 2); } return e;
}
Int Rnd ()
{srand (time (NULL)); Return the rand () % 2;
}

CodePudding user response:

 # include 
#include
#include

Int Computer (int n);
Int Rnd (void);
Int main ()
{
Int x, y, m;
Printf (" Input 1 or 1, 2: ");
scanf("%d",& X);
Y=Computer (x);
For (m=x; m<=30; M++) {
Printf (" Input it continuing: ");
scanf("%d",& X);
}
If (Computer (y)==30) {
Printf (" You lose! \n");
} the else
Printf (" You win! \n");

return 0;
}
Int Computer (int n)
{
Int e, r;/* r for the random number */
R=Rnd ();
If ((e + 1) % 3==1) {
Printf (" % d ", e + 1);
} else if ((e + 1) % 3==2) {
Printf (" \ n % d, % d ", e + 1, e + 2);
} else if ((e + 1) % 3==0 & amp; & R % 2==0) {
Printf (" % d ", e + 1);
//} else if ((e + 1) % 3==0 & amp; & R % 2==1); {
} else if ((e + 1) % 3==0 & amp; & R % 2==1) {
Printf (" \ n % d, % d ", e + 1, e + 2);
}
return e;
}

Int Rnd ()
{
Srand (time (NULL));
Return the rand () % 2;
}

For your reference ~

More than a semicolon ~
  • Related