#include <iostream>
#include <vector>
#include <map>
enum class Mode {
EQ = -1,
AS = -2,//昇順
DES = -3,//降順
NotGood = -4,
Zero=0,
};
int SortedType(const std::vector<int>& vec){
std::map < Mode, int > M = {{ Mode::EQ, 1 }, { Mode::DES, 1}, { Mode::AS, 1 }, };
if (vec.size() < 2) return static_cast<int>(Mode::EQ);
bool IsUpper = false;
std::size_t i = 0;
int OR = 0;
for (i = 1; i < vec.size(); i++){
if ((vec[i - 1] != vec[i])) M[Mode::EQ] = 0;
if ((vec[i - 1] > vec[i])) M[Mode::AS] = 0;
if ((vec[i - 1] < vec[i])) M[Mode::DES] = 0;
for (auto& o : M) OR |= o.second;
if (OR == 0) return i;
OR = 0;
}
if (M[Mode::EQ] == 1) return static_cast<int>(Mode::EQ);
if (M[Mode::DES] == 1) return static_cast<int>(Mode::DES);
if (M[Mode::AS] == 1) return static_cast<int>(Mode::AS);
return static_cast<int>(Mode::NotGood);
}
bool Judge(const std::vector<int>& vec, int N){
std::cout <<'[';
for (auto& o : vec) std::cout << o << ',';
std::cout <<']';
if (N == static_cast<int>(Mode::EQ)) std::cout << " = > " << "EQ" << std::endl;
if (N == static_cast<int>(Mode::AS)) std::cout << " = > " << "AS" << std::endl;
if (N == static_cast<int>(Mode::DES)) std::cout << " = > " << "DES" << std::endl;
if (N >=0) std::cout << " = > " << N << std::endl;
return true;
}
int main(){
int R = 0;
std::vector<int> vec;
vec = { 6, 6, 3, 2, 6, 4, 7, 4, 7, 4 };
R= SortedType(vec);// = > 4
Judge(vec, R);
vec = { 2, 3, 4, 4, 4, 6, 6, 6, 7, 7 };// = > AS
R= SortedType(vec);// = > 4
Judge(vec, R);
vec = { 7, 7, 6, 6, 6, 4, 4, 4, 3, 2 };// = > DES
R= SortedType(vec);// = > 4
Judge(vec, R);
vec={1, 1, 1, 1, 1, 1, 1, 1, 1, 1};// = > EQ
R= SortedType(vec);// = > 4
Judge(vec, R);
vec={};// = > EQ
R= SortedType(vec);// = > 4
Judge(vec, R);
vec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