#28614: 請問哪裡錯了??


s010563@student.cysh.cy.edu.tw (林家緯)

學校 : 不指定學校
編號 : 162212
來源 : [163.27.3.89]
最後登入時間 :
2022-01-13 13:42:24
b428. 凱薩加密 | From: [114.39.40.102] | 發表日期 : 2021-12-21 21:37

#include <iostream>

 

using namespace std;

 

int main()

{

    int ans;

    string s,t;

    while(getline(cin,s) && getline(cin,t))

    {

        ans=max(s[0],t[0])-min(s[0],t[0]);

        cout<<ans<<endl;

    }

 

    return 0;

}

 
#28617: Re:請問哪裡錯了??


Ststone1687 (Ststone)

學校 : 新北市立板橋高級中學
編號 : 124999
來源 : [101.136.76.3]
最後登入時間 :
2024-04-29 11:15:42
b428. 凱薩加密 | From: [114.34.121.104] | 發表日期 : 2021-12-21 23:03

#include

 

using namespace std;

 

int main()

{

    int ans;

    string s,t;

    while(getline(cin,s) && getline(cin,t))

    {

        ans=max(s[0],t[0])-min(s[0],t[0]);

        cout<<ans<<endl;

    }

 

    return 0;

}


試試看
Z
A
這組喔。
這樣應該是1才對。

不能用min max,這樣前比後大就會有問題喔。

 
ZeroJudge Forum