#33096: cpp


yp11151025@yphs.tp.edu.tw (803-23江紘宇)

學校 : 臺北市私立延平高級中學
編號 : 196814
來源 : [203.72.178.1]
最後登入時間 :
2024-01-15 16:38:36
c290. APCS 2017-0304-1秘密差 -- 2017年3月APCS | From: [203.72.178.1] | 發表日期 : 2022-11-30 17:18

#include<iostream>
using namespace std;
int main(){
    string s;
    int A,B;
    while(cin>>s){
        A=B=0;
        for(int i=0;i<s.length();i++){
            if(i%2) A+=s[i]-'0';
            else    B+=s[i]-'0';
            
        }
        if(A>B) cout<<A-B<<endl;
        else    cout<<B-A<<endl;
    }

}

 
ZeroJudge Forum