Onboarding

来源:互联网 发布:源码分享是什么意思 编辑:程序博客网 时间:2024/04/30 13:11

Description

A tutorial mission for newcomers. Defend the planet with a big laser cannon from the invading insectoid alien ships. 


很简单,只要判断哪个离得近就行了,下面是代码

#include <iostream>#include <string>#include <vector>#include <algorithm>using namespace std;/** * Auto-generated code below aims at helping you parse * the standard input according to the problem statement. **/int main(){    // game loop    while (1) {        string enemy1;        cin >> enemy1; cin.ignore();        int dist1;        cin >> dist1; cin.ignore();        string enemy2;        cin >> enemy2; cin.ignore();        int dist2;        cin >> dist2; cin.ignore();        if (dist1 < dist2)            cout << enemy1 << endl;        else            cout << enemy2 << endl;    }}


0 0
原创粉丝点击