Created
March 15, 2023 20:39
-
-
Save stefanoverna/9a3175264afb273147cf6036d90dd26e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <string.h> | |
struct KeyPoint | |
{ | |
char key; | |
char points; | |
}; | |
struct KeyPoint rules[] = { | |
{'a', 10}, | |
{'s', 5}, | |
{'d', 2}, | |
{'f', 1}}; | |
int main() | |
{ | |
char combo[100] = ""; | |
printf("Inserisci combo:\n"); | |
scanf("%s", combo); | |
int totalPoints = 0; | |
for (int i = 0; i < strlen(combo); i++) | |
{ | |
char key = combo[i]; | |
for (int j = 0; j < sizeof(rules); j++) | |
{ | |
if (rules[j].key == key) { | |
totalPoints += rules[j].points; | |
break; | |
} | |
} | |
} | |
printf("Totale: %d\n", totalPoints); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment