init
This commit is contained in:
commit
ca9736d8ec
122 files changed
+28514
No files matched your search
@@ -0,0 +1,102 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
/*
|
||||
KEY
|
||||
|
||||
A, X R 1
|
||||
B, Y P 2
|
||||
C, Z S 3
|
||||
|
||||
win 6
|
||||
lose 0
|
||||
draw 3
|
||||
|
||||
3 6 You: Scissors; Them: Paper (win)
|
||||
3 3 You: Scissors; Them: Scissors (tie)
|
||||
2 0 You: Paper; Them: Scissors (lose)
|
||||
9+6+2
|
||||
*/
|
||||
|
||||
|
||||
|
||||
int main()
|
||||
{
|
||||
|
||||
FILE *File;
|
||||
char Line[6];
|
||||
|
||||
int TotalScore = 0;
|
||||
|
||||
File = fopen("input.txt", "r");
|
||||
|
||||
while (fgets(Line, 6, File) != NULL)
|
||||
{
|
||||
|
||||
int Score = 0;
|
||||
|
||||
char Me = Line[2];
|
||||
char Opponent = Line[0];
|
||||
|
||||
printf("%c %c\n", Me, Opponent);
|
||||
|
||||
if (Me == 'X')
|
||||
{
|
||||
Score += 1;
|
||||
|
||||
printf("You played Rock! +1\n");
|
||||
|
||||
if (Opponent == 'C') // Scissors (win)
|
||||
{
|
||||
Score += 6;
|
||||
printf("You won! +6\n");
|
||||
}
|
||||
else if (Opponent == 'A') // Rock (tie)
|
||||
{
|
||||
Score += 3;
|
||||
printf("Tie! +3\n");
|
||||
}
|
||||
}
|
||||
else if (Me == 'Y')
|
||||
{
|
||||
Score += 2;
|
||||
|
||||
printf("You played Paper! +2\n");
|
||||
|
||||
if (Opponent == 'A') // Rock (win)
|
||||
{
|
||||
Score += 6;
|
||||
printf("You won! +6\n");
|
||||
}
|
||||
else if (Opponent == 'B') // Paper (tie)
|
||||
{
|
||||
Score += 3;
|
||||
printf("Tie! +3\n");
|
||||
}
|
||||
}
|
||||
else if (Me == 'Z')
|
||||
{
|
||||
Score += 3;
|
||||
|
||||
printf("You played Scissors! +3\n");
|
||||
|
||||
if (Opponent == 'B') // Paper (win)
|
||||
{
|
||||
Score += 6;
|
||||
printf("You won! +6\n");
|
||||
}
|
||||
else if (Opponent == 'C') // Scissors (tie)
|
||||
{
|
||||
Score += 3;
|
||||
printf("Tie! +3\n");
|
||||
}
|
||||
}
|
||||
TotalScore += Score;
|
||||
}
|
||||
|
||||
printf("Total score was %d\n",TotalScore);
|
||||
|
||||
fclose(File);
|
||||
|
||||
return 0;
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,83 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
|
||||
FILE *File;
|
||||
char Line[6];
|
||||
|
||||
int TotalScore = 0;
|
||||
|
||||
File = fopen("input.txt", "r");
|
||||
|
||||
while (fgets(Line, 6, File) != NULL)
|
||||
{
|
||||
|
||||
int Score = 0;
|
||||
|
||||
char Me = Line[2];
|
||||
char Opponent = Line[0];
|
||||
|
||||
if (Me == 'X') // Lose
|
||||
{
|
||||
// O: Rock, Y: Scissors
|
||||
if (Opponent == 'A')
|
||||
Score += 3;
|
||||
|
||||
// O: Paper, Y: Rock
|
||||
else if (Opponent == 'B')
|
||||
Score += 1;
|
||||
|
||||
// O: Scissors, Y: Paper
|
||||
else if (Opponent == 'C')
|
||||
Score += 2;
|
||||
|
||||
}
|
||||
else if (Me == 'Y') // Draw
|
||||
{
|
||||
|
||||
Score += 3;
|
||||
|
||||
// O: Rock, Y: Rock
|
||||
if (Opponent == 'A')
|
||||
Score += 1;
|
||||
|
||||
// O: Paper, Y: Paper
|
||||
else if (Opponent == 'B')
|
||||
Score += 2;
|
||||
|
||||
// O: Scissors, Y: Scissors
|
||||
else if (Opponent == 'C')
|
||||
Score += 3;
|
||||
|
||||
}
|
||||
else if (Me == 'Z') // Win
|
||||
{
|
||||
|
||||
Score+=6;
|
||||
|
||||
// O: Rock, Y: Paper
|
||||
if (Opponent == 'A')
|
||||
Score += 2;
|
||||
|
||||
// O: Paper, Y: Scissors
|
||||
else if (Opponent == 'B')
|
||||
Score += 3;
|
||||
|
||||
// O: Scissors, Y: Rock
|
||||
else if (Opponent == 'C')
|
||||
Score += 1;
|
||||
|
||||
}
|
||||
|
||||
TotalScore += Score;
|
||||
}
|
||||
|
||||
|
||||
printf("Total score was %d\n",TotalScore);
|
||||
|
||||
fclose(File);
|
||||
|
||||
return 0;
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
Reference in new issue
Block a user