#28614: 請問哪裡錯了??


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

學校 : 不指定學校
編號 : 162212
來源 : [163.27.3.89]
最後登入時間 :
2022-01-13 13:42:24

#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.138.211.230]
最後登入時間 :
2025-10-05 12:08:25

#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,這樣前比後大就會有問題喔。