This is an archive of a previous version of Sodarace.

Please visit http://sodarace.net for the latest version.

forum  |  »» sodaplay
 
»» forums  »» community discussion forum

subject: Do you want to learn to program in C

357 replies on 24 pages. most recent reply: Tues, Aug 28 10:58 PM by matthew102000

»» back to topic list  

This topic has 357 replies on 24 pages [ « | 1 ... 20 21 22 23 24 | » ]
»» previous topic   »» next topic  


matthew102000

»» models

Re: Do you want to learn to program in C   posted: 09-Jul-07 23:10   »» 
well it isnt working. with this cheat i was able to get myself somewhere aroung 500,000 credits. i could have gone even higher., but i didnt feel like it. and you can set the amount of #s to 99 at the highest. then bet more than you have, pick 20 numbers, and win alon of money. somethings wrong with it.

matt wuz here

cactus2

»» models

Re: Do you want to learn to program in C   posted: 09-Jul-07 23:39   »» 
I believe the main problem is in the bet amount, as the code handles too many or too little picks without telling you that it has. This code should handle that. I noticed you didn't included it in the last copy of code you posted.
do{
printf("What is your bet? You have %f credits", winnings);
scanf("%f", &bet);
}while(bets>winnings||bets<0);

matthew102000

»» models

Re: Do you want to learn to program in C   posted: 10-Jul-07 16:25   »» 
could you add it in. i dont know where it goes.

matt wuz here

cactus2

»» models

Re: Do you want to learn to program in C   posted: 10-Jul-07 20:09   »» 
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main (void)
{
char response[10];
int n=0;
int n2=0;
int picknum=0;
int picks[20];
int randomnumbers[20];
int correct=0;
float bet=0;
float winnings=100;

srand(time(NULL)); //Seed the random nubmer generator
do{
n=0;
n2=0;
correct=0;
printf("How many numbers do you want to pick?");
scanf("%d", &picknum);
if(picknum>20) picknum=20;
if(picknum<1) picknum=1;
do{
printf("What is your bet? You have %f credits", winnings);
scanf("%f", &bet);
}while(bet>winnings);
while(n<picknum)
{
scanf("%d", picks+n);
if(picks[n]<80&&picks[n]>0) n++;
}
n=0;
while(n<20)
{
int test=rand()%80+1:
while(n2<n) //Check every value to make sure it isn't a duplicate
{
if(test==randomnumbers[n2]) break;
n2++;
}
if(n2==n)//If the while loop didn't break, they would be equal
{
randomnumbers[n]=test;
n++;
}
n2=0;
}
n=0;
n2=0;
while(n<picknum)
{
while(n2<20)
{
if(picks[n]==randomnumbers[n2]) correct++;
n2++;
}
n2=0;
n++;
}

//Don't know the scoring formula. Paste it here.
winnings+=((picknum*bet*correct)/10);
prinft("You had %i correct. Your current number of credits is %f. Continue?(Y/N)", correct, winnings);
scanf("%s", response);
if(response[0]=='N' || response[0]='n') break;
}while(winnings>0);
printf("You have won %i credits", winnings);
}

matthew102000

»» models

Re: Do you want to learn to program in C   posted: 10-Jul-07 22:19   »» 
i revised it a little more...

#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <windows.h>
#include <conio.h>
int main (void)
{
char response[10];
int n=0;
int n2=0;
int picknum=0;
int picks[20];
int randomnumbers[20];
int correct=0;
float bet=0;
float winnings=100;

srand(time(NULL)); //Seed the random nubmer generator
do{
n=0;
n2=0;
correct=0;
printf("How many numbers do you want to pick? (1-20)\n \n \t - ");
scanf("%d", &picknum);
if(picknum>20) picknum=20;
if(picknum<1) picknum=1;
Beep(600, 100);
system("CLS");
do{
printf("What is your bet? You have %f credits\n \n \t - ", winnings);
scanf("%f", &bet);
Beep(600, 100);
system("CLS");
printf("Type the numbers you want to pick. After every number, hit enter.\n Repeat as nessissary.\n \n");
}while(bet>winnings);
while(n<picknum)

{
scanf("%d", picks+n);
if(picks[n]<80&&picks[n]>0) n++;
}
n=0;
while(n<20)
{
int test=rand()%80+1;
while(n2<n) //Check every value to make sure it isn't a duplicate
{
if(test==randomnumbers[n2]) break;
n2++;
}
if(n2==n)//If the while loop didn't break, they would be equal
{
randomnumbers[n]=test;
n++;
}
n2=0;
}
n=0;
n2=0;
while(n<picknum)
{
while(n2<20)
{
if(picks[n]==randomnumbers[n2]) correct++;
n2++;
}
n2=0;
n++;
}

//Don't know the scoring formula. Paste it here.
winnings+=((picknum*bet*correct)/10);
printf("You had %i correct. Your current number of credits is %f. Continue?(Y/N)\n \n \t - ", correct, winnings);
scanf("%s", response);
Beep(600, 100);
system("CLS");
if(response[0]=='N' || response[0]=='n') break;
}while(winnings>0);
printf("You have won %i credits", winnings);
}

is there any way to make it so that you wont win any money and will lose your bet if you dont get enough numbers right???

matt wuz here

cactus2

»» models

Re: Do you want to learn to program in C   posted: 10-Jul-07 23:01   »» 
Why not change the formula so that you'll win only if at least 25% of your picks were correct?
winnings+=floor((bet*((correct/picks)-0.25)));

cactus2

»» models

Re: Do you want to learn to program in C   posted: 10-Jul-07 23:01   »» 
STDP
Add "include <math.h>"

matthew102000

»» models

Re: Do you want to learn to program in C   posted: 11-Jul-07 03:28   »» 
i bet all 100 of my credits. did a twenty spot, put 1 for all my numbers, got them all wrong, and only lost half a credit. we need to make it so you lose more!!!

matt wuz here

cactus2

»» models

Re: Do you want to learn to program in C   posted: 11-Jul-07 11:40   »» 
Sorry, messed up the formula a bit.
winnings+=floor((bet*((correct/picknum)-0.25)));

matthew102000

»» models

Re: Do you want to learn to program in C   posted: 11-Jul-07 17:03   »» 
i just figured out that you can bet negitive numbers. i tried the |absolute value| line thingies, but it didnt work. any other ideas???

matt wuz here

ps i wont be here for five days. going camping.

matt wuz here (again)

cactus2

»» models

Re: Do you want to learn to program in C   posted: 11-Jul-07 18:47   »» 
In the while statement after the do, add ||bet<0 so that it is }while(bet>winnings || bet<0)

matthew102000

»» models

Re: Do you want to learn to program in C   posted: 14-Jul-07 20:18   »» 
ok. it worked. now to adress the barely being able to lose anything problem. im thinking mabey we start out with 50 credits, or mabey even as low as 10. then, we make it so the scoring formula is really clos to zero, so you can get negitive, and positive numbers out of it. the negitive numbers wuold get rid of money, while the positive numbers would add money. wha do you think???

matt wuz here

matthew102000

»» models

Re: Do you want to learn to program in C   posted: 14-Jul-07 23:48   »» 
oh and also im trying to get this to work. somthing is wrong wih the break statment.

#include <stdio.h>
#include <windows.h>
#include <math.h>
#include <conio.h>
int main (void)
{
int pass;
int answer;
{
do
{
printf("What do you want the 4 digit password to be???\n \n \t - ");
scanf("%i", &pass);
}
while (pass<=9999);
system("CLS");
Beep(1000, 999999999);
printf("enter password\n \n \t - ");
scanf("%i", &answer);
{
if(answer==pass) break;
}
do
{
system("CLS");
printf("!!!INCORRECT PASSWORD!!!\n \n enter password \n \n \t - ");
}
while (answer != pass);
}
return 0;
}

line 21: break statement not within loop or switch.

matt wuz here

cactus2

»» models

Re: Do you want to learn to program in C   posted: 15-Jul-07 12:42   »» 
#include <stdio.h>
#include <windows.h>
#include <math.h>
#include <conio.h>
int main (void)
{
int pass;
int answer;
{
do
{
printf("What do you want the 4 digit password to be???\n \n \t - ");
scanf("%i", &pass);
}
while (pass>9999);
system("CLS");
do
{
Beep(1000, 999999999);
printf("enter password\n \n \t - ");
scanf("%i", &answer);
if(answer==pass) break;
system("CLS");
printf("!!!INCORRECT PASSWORD!!!\n \n enter password \n \n \t - ");
}
while (answer != pass);
}
return 0;
}

Not sure how to modify the formula for the bets.

edlinfan

»» models
»» homepage

Re: Do you want to learn to program in C   posted: 20-Jul-07 17:44   »» 
This got buried under a spam wave, so I take it upon myself to >BUMP<.



This topic has 357 replies on 24 pages [ « | 1 ... 20 21 22 23 24 | » ]


»» previous topic   »» next topic  

»» back to topic list  »» top of the page  

PLEASE READ THE FORUM GUIDELINES AND ALWAYS PREVIEW TO CHECK MESSAGES BEFORE POSTING...
...Help keep our forums creative and constructive. Thank you.


»» forum home