Sep 1, 2018 · 1 min read
심심해서 2번 풀어봤는데
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
bool solution(vector<int> v)
{
int n = v.size();
for (int i = 0; i < n; i++)
if (i + 1 != v[i])
return false;
return true;
}
int main()
{
int tmp;
vector<int> v;
scanf(“[%d”, &tmp);
cout << tmp << endl;
v.push_back(tmp);
while (scanf(“,%d”, &tmp))
{
//cout << tmp << endl;
v.push_back(tmp);
if (scanf(“]”))
break;
}
sort(v.begin(), v.end());
solution(v) ? cout << “true\n” : cout<<”false\n”;
}
맞나요?