now i slowly got it. need time to digest.. try and error.... As I've been saying...
Make a table in your HTML file and fill it in with your results.
now i slowly got it. need time to digest.. try and error.... As I've been saying...
Make a table in your HTML file and fill it in with your results.
switch look neater i guess. hahaI see but only 3 building blocks with this game in computer code.
a. Player input to select their move (paper, rock or scissors)
b. Computer to random generate number 0 to 2 (0 equates to paper, 1 for rock, 2 for scissors)
c. Logic to decide winner & print on screen. 3-Bit boolean table.
Nice to see you are using the switch statement. Keep using it...
i got it!!!!!!!!!! thank you!!!!... As I've been saying...
Make a table in your HTML file and fill it in with your results.
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
main()
{
int ch1, ch2, round, temp, tie, i=0, round2=0, count1=0, count2=0, total=0, c=2;
float perc1, perc2, perc3;
printf("\n\n\tThis is the paper rock scissor game");
FILE* f=fopen("<trial1>.htm","w");
if (f !=NULL)
{
char* text = "<html><body><Table border=1 style=width:100%>The Result<TR><td>Player1</td><TD>Weapon</TD><TD>win/lose</TD><td>change weapon?</td></TR>";
fprintf(f,"%s",text);
for(round=1; round<=10; round++)
{
srand(time(NULL));
total++;
fprintf(f,"<tr><td>Match %d</td>",round);
printf("\n\nYou may choose \n'1' for paper\n'2' for rock\n'3' for scissor");
printf("\n\nPlayer 1 make a choose :");
scanf("%d", &ch1);
ch2=rand()%3+1;
switch (ch1)
{
case 1: printf("\n\nYou has choose paper");
char* text2= "Paper";
fprintf(f,"<td>%s</td>",text2);
break;
case 2: printf("\n\nYou has choose rock");
char* text3= "Rock";
fprintf(f,"<td>%s</td>",text3);
break;
case 3: printf("\n\nYou has choose scissor");
char* text4= "Scissor";
fprintf(f,"<td>%s</td>",text4);
break;
default: printf("\n\nInvalid input");
break;
}
switch (ch2)
{
case 1: printf("\nThe PC has choose paper");
break;
case 2: printf("\nThe PC has choose rock");
break;
case 3: printf("\nThe PC has choose scissor");
break;
default: printf("\nInvalid input");
break;
}
if(ch1==1 && ch2==2)
{
char* text5="Lose";
fprintf(f,"<td>%s</td>",text5);
count2++;
}
else if(ch1==1 && ch2==3)
{
char* text6="Lose";
fprintf(f,"<td>%s</td>",text6);
count2++;
}
else if(ch1==1 && ch2==1)
{
char* text7="Tie";
fprintf(f,"<td>%s</td>",text7);
}
else if(ch1==2 && ch2==1)
{
char* text8="Win";
fprintf(f,"<td>%s</td>",text8);
count1++;
}
else if(ch1==2 && ch2==2)
{
char* text9="Tie";
fprintf(f,"<td>%s</td>",text9);
}
else if(ch1==2 && ch2==3)
{
count2++;
char* text10="Lose";
fprintf(f,"<td>%s</td>",text10);
}
else if(ch1==3 && ch2==1)
{
count1++;
char* text11="Win";
fprintf(f,"<td>%s</td>",text11);
}
else if(ch1==3 && ch2==2)
{
count2++;
char* text12="Lose";
fprintf(f,"<td>%s</td>",text12);
}
else if(ch1==3 && ch2==3)
{
char* text13="Tie";
fprintf(f,"<td>%s</td>",text13);
}
temp=ch1;
for(i=c; i<=round; i++)
{
if(temp==ch1)
{
char* text14="same weapon";
fprintf(f,"<td>%s</td></tr>",text14);
}
else if(ch1==1 && ch1!=temp)
{
char* text15="change : paper";
fprintf(f,"<td>%s</td></tr>",text15);
printf("\nchange : paper");
}
else if(ch1==2 && ch1!=temp)
{
char* text17="change : rock";
fprintf(f,"<td>%s</td></tr>",text17);
}
else if(ch1==3 && ch1!=temp)
{
char* text18="same weapon";
fprintf(f,"<td>%s</td></tr>",text18);
}
c++;
}
}
}
perc1=((float)count1/10)*100;
perc2=((float)count2/10)*100;
printf("\nThe score is player1\n");
fprintf(f,"<tr><td>Ratio = %.2f</td></tr></table></body></html>",perc1);
fclose(f);
}
Good! I'm glad to hear it!i got it!!!!!!!!!! thank you!!!!
[...]
yeah. i'm very glad because you help me a lot!! thank you i want to make it look more neater. heheGood! I'm glad to hear it!
You could clean your code up a bit, but the functionality is the important part...
Cleaning up the code is a good idea. But! Save a working copy first. It is very common to "break" a program when trying to improve it.yeah. i'm very glad because you help me a lot!! thank you i want to make it look more neater. hehe
Yes, i have made a copy. Jus afraid if the code doesnt work after cleaning it. Thank youCleaning up the code is a good idea. But! Save a working copy first. It is very common to "break" a program when trying to improve it.
by Aaron Carman
by Duane Benson