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 ... 18 19 20 21 22 23 24 | » ]
»» previous topic   »» next topic  


cactus2

»» models

Re: Do you want to learn to program in C   posted: 22-Jun-07 18:20   »» 
Sorry, I don't know how Windows Vista processes HTML, considering I run Windows XP.

matthew102000

»» models

Re: Do you want to learn to program in C   posted: 22-Jun-07 21:03   »» 
ok. it was just a suguestion. but i can give you all the specs you'll need.

matt wuz here

matthew102000

»» models

Re: Do you want to learn to program in C   posted: 23-Jun-07 17:36   »» 
blink and you'll miss it. this is the length of the shortest tv commercial ever!

#include <stdio.h>
#include <windows.h>
#include <conio.h>
int main (void)
{
Sleep(1000);
printf(" H H IIIII \n");
printf(" H H I \n");
printf(" HHHHHHH I \n");
printf(" H H I \n");
printf(" H H IIIII \n");
Sleep(16.66666666666666666666666);
system ("cls");
Sleep(1000);
printf("could you read that???");
Sleep(2000);
return 0;
}

can you read it when it blinks???

matt wuz here

matthew102000

»» models

Re: Do you want to learn to program in C   posted: 23-Jun-07 17:38   »» 
oops! i forgot. spaces dont work here

#include <stdio.h>
#include <windows.h>
#include <conio.h>
int main (void)
{
Sleep(1000);
printf(" H-----H---IIIII-\n");
printf(" H-----H-----I-----\n");
printf(" HHHHHHH-----I-----\n");
printf(" H-----H-----I-----\n");
printf(" H-----H IIIII-\n");
Sleep(16.66666666666666666666666);
system ("cls");
Sleep(1000);
printf("could you read that???");
Sleep(2000);
return 0;
}

matthew102000

»» models

Re: Do you want to learn to program in C   posted: 23-Jun-07 17:39   »» 
sorry! im an idiot! i forgot a line of -'s!

oops! i forgot. spaces dont work here

#include <stdio.h>
#include <windows.h>
#include <conio.h>
int main (void)
{
Sleep(1000);
printf(" H-----H---IIIII-\n");
printf(" H-----H-----I-----\n");
printf(" HHHHHHH-----I-----\n");
printf(" H-----H-----I-----\n");
printf(" H-----H---IIIII-\n");
Sleep(16.66666666666666666666666);
system ("cls");
Sleep(1000);
printf("could you read that???");
Sleep(2000);
return 0;
}

sorry!!!!!!!!!!!!!!!!!!!!

matt wuz here

tonywyatt

»» models
»» homepage

Re: Do you want to learn to program in C   posted: 24-Jun-07 17:37   »» 
Uh.. both are exactly the same.

~Toneo

tonywyatt

»» models
»» homepage

Re: Do you want to learn to program in C   posted: 24-Jun-07 18:00   »» 
Sorry, didn't notice. Difference too small.

~Toneo

matthew102000

»» models

Re: Do you want to learn to program in C   posted: 07-Jul-07 01:10   »» 
hey guys. i have an idea for a game. if you havent heard of the game keno, its a casino game where there is a ig board with the numbers 1-80 on it. you bick some numbers and the board picks twenty of them. i was thinking of putting this into a program but i dont know how. any help.

matt wuz here

cactus2

»» models

Re: Do you want to learn to program in C   posted: 07-Jul-07 13:18   »» 
Hmm... Maybe something like this? Please excuse any syntax errors I made.
It uses stdio.h, stdlib.h, and time.h

int n=0;
int n2=0;
int picknum=0;
int picks[20];
int randomnumbers[20];
int correct=0;
float bet=0;
float currentwinnings=100;

srand(time(NULL)); //Seed the random nubmer generator
do{
printf("How many numbers do you want to pick?");
scanf("%d", &picknum);
if(picknum>20) picknum=20;
if(picknum<1) picknum=1;
printf("What is your bet? You have %f credits", ¤twinnings);
scanf("%f", &bet);

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.
{
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.
}while(currentwinnings>0);

For information on the functions, go here.
http://www.cplusplus.com/reference/clibrary/cstdlib/rand.html

cactus2

»» models

Re: Do you want to learn to program in C   posted: 07-Jul-07 18:32   »» 
STDP. Insert "n=0;n2=0;" below the do{ line.

matthew102000

»» models

Re: Do you want to learn to program in C   posted: 07-Jul-07 21:07   »» 
the is a prob w/ this line

printf("What is your bet? You have %f credits", ¬twinnings);

whats this anyway??? ¬

also, sence i was not the programmer, this is a little confusing. but for the winnings, why dont we just use this formula...

(amount of #'s correct / amount of numbers) * 100

heres the hole code just in case you need it...

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

srand(time(NULL)); //Seed the random nubmer generator
do{
n=0;n2=0;
printf("How many numbers do you want to pick?");
scanf("%d", &picknum);
if(picknum>20) picknum=20;
if(picknum<1) picknum=1;
printf("What is your bet? You have %f credits", ¬twinnings);
scanf("%f", &bet);

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.
{
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.
}while(currentwinnings>0);

feel free to correct the code if there was other stuff that i needed to ad in and didnt.

matt wuz here

matthew102000

»» models

Re: Do you want to learn to program in C   posted: 07-Jul-07 21:45   »» 
oops... slight flaw with my calculating system. i never took into account the amount of credits bet. hmm... lets see... how should i do ths???

OH!!! got it.

{[(amount of # * credits bet) / 100] * # of correct #} * 10 = winnings

a little confusing, but sounds about right.

so if you bet 5 credits, chose to do an 8 spot, and got 4 right you would end up with 16 credits.

you should also make it so that you can only get credits depending on how many you got. like foran eight spot, you need to get at least four to get credits to win some credits.

hope that made sence...

matt wuz here

cactus2

»» models

Re: Do you want to learn to program in C   posted: 08-Jul-07 13:36   »» 
Yeah, sorry, the weird symbol was an ampersand.

#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 currentwinnings=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;
printf("What is your bet? You have %f credits", &winnings);
scanf("%f", &bet);

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.
currentwinnings+=((picknum*bet*correct)/10);
prinft("You had %i correct. Your current number of credits is %f. Continue?(Y/N)", &correct, ¤twinnings);
scanf("%s", response);
if(response[0]=='N' || response[0]='n') break;
}while(currentwinnings>0);
printf("You have won %i credits", currentwinnings);
}

cactus2

»» models

Re: Do you want to learn to program in C   posted: 08-Jul-07 13:36   »» 
For some reason it would let me post & . Just replace the wierd symbol and t with &.

cactus2

»» models

Re: Do you want to learn to program in C   posted: 08-Jul-07 13:38   »» 
STTP. I figured out why. & current is an HTML entity, internet browsers automatically change them to that.



This topic has 357 replies on 24 pages [ « | 1 ... 18 19 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