#45714: ASCII碼(a=97)


yp11351280@yphs.tp.edu.tw (710-43)

學校 : 臺北市私立延平高級中學
編號 : 276272
來源 : [1.164.243.217]
最後登入時間 :
2025-04-08 22:18:39
d086. 態度之重要的證明 -- 成功電研20th~21st C++ ~最後的競賽~ | From: [118.168.105.15] | 發表日期 : 2025-04-04 13:33

#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;}
    }
}

 

 
ZeroJudge Forum