類比 HDOJ 5099 Comparison of Android versions

來源:互聯網
上載者:User

標籤:

 

題目傳送門

 1 /* 2     題意:比較型號的大小 3     類比:坑點在長度可能為5,此時設為‘A‘ 4 */ 5 #include <cstdio> 6 #include <algorithm> 7 #include <iostream> 8 #include <cstring> 9 #include <cmath>10 #include <string>11 #include <vector>12 #include <queue>13 #include <map>14 #include <set>15 #include <ctime>16 #include <cstdlib>17 using namespace std;18 19 const int MAXN = 1e4 + 10;20 const int INF = 0x3f3f3f3f;21 char s1[10], s2[10];22 23 char check(void)24 {25     for (int i=2; i<=4; ++i)26     {27         if (s1[i] < s2[i])    return ‘<‘;28         else if (s1[i] > s2[i])    return ‘>‘;29     }30 31     if (s1[1] == s2[1])32     {33         if (s1[5] == ‘\0‘)    s1[5] = ‘A‘;34         if (s2[5] == ‘\0‘)    s2[5] = ‘A‘;35         if (s1[5] < s2[5])    return ‘<‘;36         else if (s1[5] > s2[5])    return ‘>‘;37     }38 39     return ‘=‘;40 }41 42 int main(void)        //HDOJ 5099    Comparison of Android versions43 {44     //freopen ("J.in", "r", stdin);45 46     int t, cas = 0;    scanf ("%d", &t);47     while (t--)48     {49         scanf ("%s%s", s1, s2);50         char ch1 = (s1[0] == s2[0]) ? ‘=‘ : (s1[0] < s2[0]) ? ‘<‘ : ‘>‘;51         char ch2 = check ();52         printf ("Case %d: %c %c\n", ++cas, ch1, ch2);53     }54 55     return 0;56 }57 58 /*59 Case 1: > >60 Case 2: = <61 */

 

類比 HDOJ 5099 Comparison of Android versions

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.