华为机试1

来源:互联网 发布:中信总行程序员待遇 编辑:程序博客网 时间:2024/06/05 15:40

#include <iostream>

#include <string>

using namespacestd;


int getInt(string s) {

    if (s[0] =='-') {

        return0;

    }

    int ret =0;

    for (int i =0; i < s.length(); ++ i) {

        ret = ret * 10 + s[i] -'0';

    }

    return ret;

}


int main(int argc,constchar * argv[]) {

    string a[4];

    while (cin >> a[0] >> a[1] >> a[2] >> a[3]) {

        int max =-1, ret =0, tmp =0;

        for (int i =0; i <4; ++ i) {

            if (a[i].length()<4) {

                tmp = getInt(a[i]);

                if (tmp <=150 && tmp >=0 && tmp > max) {

                    max = tmp;

                    ret = i + 1;

                }

            }

        }

        cout << ret;

    }

}


0 0
原创粉丝点击