# 13309 - How much is the string worth 2 >author: Utin ###### tags: `string` --- ## Brief See the code below ## Solution 0 ```c= #include <stdio.h> #include <string.h> char c[29], s[101]; int indexOf(char target) { for(int i=0; i<26; i++) { if(target == c[i]) return i+1; } return 0; } int check(int l) { if(s[0] == '0' && l == 2) return 1; else if(s[0] == 'e' && s[1] == 'n' && s[2] == 'd' && l == 4) return 1; else return 0; } int main() { fgets(c, 28, stdin); while (fgets(s, 100, stdin) != EOF) { int length = strlen(s); if(check(length) == 1) { break; } int sum = 0; for(int i=0; i<length-1; i++) { sum += indexOf(s[i]); } printf("%d\n", sum); } } // By Utin ``` ## Reference
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up