• <input id="auww4"></input>
  • <input id="auww4"><acronym id="auww4"></acronym></input>
  • <input id="auww4"><u id="auww4"></u></input>
    <object id="auww4"><acronym id="auww4"></acronym></object>
    <menu id="auww4"></menu><input id="auww4"><u id="auww4"></u></input>
    <input id="auww4"><u id="auww4"></u></input>
  • F.A.Q
    Hand In Hand
    Online Acmers
    Forum | Discuss
    Statistical Charts
    Problem Archive
    Realtime Judge Status
    Authors Ranklist
     
         C/C++/Java Exams     
    ACM Steps
    Go to Job
    Contest LiveCast
    ICPC@China
    Best Coder beta
    VIP | STD Contests
    Virtual Contests
        DIY | Web-DIY beta
    Recent Contests
    Author ID 
    Password 
     Register new ID

    Re:AC代碼,C++精簡

    Posted by smallerharder at 2020-05-13 21:21:56 on Problem 1002
    (99)  


    #include<iostream>
    #include<string>
    
    
    using namespace std;
    
    string a1, b1;
    int a[1003], b[1003];
    int main()
    {
        int t;
    
    
        int count = 0;
        cin >> t;
        while (t--)
        {
            int sum[1003] = { 0 };
            count++;
            cin >> a1 >> b1;
            for (int i = 1; i <= a1.length(); i++)
                a[i] = int(a1[i - 1])-48;
            int cou = 0;
            for (int j = a1.length(); j > a1.length()-b1.length(); j--)
            {
                cou++;
                b[j] = int(b1[b1.length() - cou])-48;
            }
            for (int i = a1.length(); i >= 1; i--)
            {
                int middle = a[i] + b[i];
                if (middle >= 10)
                    sum[i - 1] += 1;
                sum[i] += middle % 10;
    
            }
            cout << "Case " << count << ":" << endl;
            for (int i = 1; i <= a1.length(); i++)
                cout << a[i];
            cout << " + ";
            for (int i = a1.length() - b1.length()+1; i <=a1.length(); i++)
                cout << b[i];
            cout << " = ";
            if (sum[0] == 0)
            {
                for (int i = 1; i <= a1.length(); i++)
                    cout << sum[i];
                cout << endl;
    
            }
    
            else
            {
                for (int i = 0; i <= a1.length(); i++)
                    cout << sum[i];
                cout << endl;
    
            }
            if(t!=0)
            cout << endl;
    
    
        }
        return 0;
    }

    Followed by:


    Post your reply here:

    Author ID
    Password
    Title
    Content  
     
    Hangzhou Dianzi University Online Judge 3.0
    Copyright © 2005-2020 HDU ACM Team. All Rights Reserved.
    Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
    Total 0.015600(s) query 5, Server time : 2020-10-16 04:12:30, Gzip enabled
    棋牌