looper
BAN USER#include <iostream>
using namespace std;
#include <stdlib.h>
#include <stdio.h>
bool isCrossing(int* a, int size) {
if(size < 4)
return false;
int i = 3;
while(i < size) {
if(a[i] > a[i-2] || a[i-1] > a[i-3])
break;
i++;
}
while(i < size) {
if(a[i] < a[i-2] || a[i-1] < a[i-3])
break;
i++;
}
while(i < size) {
if(a[i] > a[i-2] || a[i-1] > a[i-3])
break;
i++;
}
if(i < size)
return true;
return false;
}
int main(int argc, char** argv) {
int size = argc -1;
int *input = new int[size];
for(int i = 0; i < size; i++)
input[i] = atoi(argv[i+1]);
if(isCrossing(input, size))
cout << "Intersects" << endl;
else
cout << "Non Intersecting" << endl;
return 1;
}
- looper September 08, 2015