hdu2054 A == B ?

#include <iostream>
#include <string>
#include <algorithm>
#include <fstream>
using namespace std;

void del(string &str);

int main()
{
    string a, b;

#ifndef ONLINE_JUDGE
    ifstream cin("d:\\UVa\\uva_in.txt");
#endif

    while (cin >> a >> b)
    {

        del(a);
        del(b);


        if (a == b)
            cout << "YES" << endl;
        else
            cout << "NO" << endl;
    }
    return 0;
}

void del(string &str)
{
    string::iterator it;
    int flag = 0;

    for (it = str.begin(); it != str.end(); it++)
    {
        if (*it == '0')
        {
            str.erase(it);
            it--;
        }
        else
            break;
    }

    for (it = str.begin(); it != str.end(); it++)
        if (*it == '.')
        {
            flag = 1;
            break;
        }

    if (flag)
    {
        reverse(str.begin(), str.end());
        for (it = str.begin(); it != str.end(); it++)
        {
            if (*it == '0')
            {
                str.erase(it);
                it--;
            }

            else
                break;
        }


        it = str.begin();
        if (*it == '.')
            str.erase(it);

        reverse(str.begin(), str.end());
    }





}

你可能感兴趣的:(String,iterator,include)