1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
|
#include <stdio.h>
int main(int argc,char** argv)
{
int testArray[] = {4,6,7,8,4,5,7,7,7,6,4,9,3};
int testValue = 5;
int numberOfValues = 13;
bool* isAbove = new bool[numberOfValues];
for (int i=0;i<numberOfValues;i++)
{
isAbove[i] = false;
}
for (int i=0;i < (numberOfValues - 2);i++)
{
if (testArray[i] > testValue &&
testArray[i+1] > testValue &&
testArray[i+2] > testValue)
{
isAbove[i] = true;
isAbove[i+1] = true;
isAbove[i+2] = true;
}
}
printf("\n");
for (int i=0;i<numberOfValues;i++)
{
if (isAbove[i] == true)
{
printf("%d +\n",testArray[i]);
}
else
{
printf("%d\n",testArray[i]);
}
}
}
|