Untitled
user_1737235546
c_cpp
2 years ago
655 B
5
Indexable
#include <stdio.h> #include <string.h> int main(){ char c[30]; int coin[26]; int tmp = 0; scanf("%s",c); for(int i = 0; i < 26; i++){ coin[c[i] - 'a'] = i+1; } char w1[] = "0 "; char w2[] = "end"; char s[105]; while(scanf("%s",s) != EOF){ int money = 0; scanf("%s",s); //printf("%s\n",s); if(strcmp(s,w1) == 0 || strcmp(s,w2) == 0){ tmp = 1; } for(int i = 0; i < strlen(s); i++){ money += coin[s[i] - 'a']; } if(tmp == 0){ printf("%d\n", money); } } return 0; }
Editor is loading...