game-engineer:classes:2022:game-programing-2:first-term:1:01-16-xx17

#include <iostream>
#include <algorithm>
#include <tuple>
#include <vector>
 
 
using std::cin;
using std::cout;
using std::endl;
using std::vector;
using std::pair;
 
 
int main()
{
	vector<pair<int, float>> n;
 
	for (int i = 0; i < 4; i++)
	{
		float tmp;
		cin >> tmp;
 
		n.push_back({i + 1, tmp});
	}
 
 
	int res = -1;
	for (int i = 1; i <= n.size(); i++)
	{
		int i0 = (i - 1) % n.size(), 
		    i1 =  i % n.size(), 
		    i2 = (i + 1) % n.size();
		if (n[i0].second /(float)n[i0].first != n[i1].second / (float)n[i1].first &&
			n[i1].second /(float)n[i1].first != n[i2].second / (float)n[i2].first)
			res = i1;		
	}
 
	cout << n[res].second << endl;
	return 0;
}
  • game-engineer/classes/2022/game-programing-2/first-term/1/01-16-xx17.txt
  • 最終更新: 3年前
  • by root