#45714: ASCII碼(a=97)


yp11351280@yphs.tp.edu.tw (810-43韓睿哲)

學校 : 臺北市私立延平高級中學
編號 : 276272
來源 : [203.72.178.1]
最後登入時間 :
2025-10-07 16:36:49

#include <iostream>
#include <string>
using namespace std;
bool CheckIfAlphabet(char Input){return (((Input>=65)&&(Input<=90))||((Input>=97)&&(Input<=122)));}//判斷是否為文字
int main(){
    string Input;
    while(cin>>Input){
        if(Input==to_string(0)){break;}
        int Sum = 0;
        for(int I=0;I<Input.length();I++){
            if(CheckIfAlphabet(Input[I])){Sum += (Input[I]<=93)?(Input[I]-'@'):(Input[I]-'`');}
            else{cout<<"Fail"<<'\n';goto Next;}
        }
        cout<<Sum<<'\n';
        Next:{continue;}
    }
}