Skip to content

Instantly share code, notes, and snippets.

@stefanoverna
Created March 15, 2023 20:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stefanoverna/9a3175264afb273147cf6036d90dd26e to your computer and use it in GitHub Desktop.
Save stefanoverna/9a3175264afb273147cf6036d90dd26e to your computer and use it in GitHub Desktop.
#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