+1 678 648 4277 

Solution


We can solve your C homework for you, or if you are unable to complete the assignment yourself then we can help with C project using the code you have already wrote.

compress.c

// Gridsville.cpp : Defines the entry point for the console application.
//

#include
#include

#define MAX_ARRAY_SIZE 100

void Compress(int *input, int *output)
{
  int current_value;
  int count;
  int output_index;

  int i;

  if (input[0] == -1)
  {
    output[0] = -1;
    return;
  }

  current_value = input[0];
  count = 1;
  output_index = 0;
  i = 1;

  while (input[i] != -1) 
  {
    if (current_value != input[i])
    {     
      output[output_index] = count;
      output_index++;
      output[output_index] = current_value;
      output_index++;

      count = 1;
      current_value = input[i];
    }
    else
    {
      count++;      
    }

    i++;
  }

  output[output_index] = count;
  output_index++;
  output[output_index] = current_value;
  output_index++;
  output[output_index] = -1;
}

int main()
{
  int input[MAX_ARRAY_SIZE] =
              { 7, 7, 7, 7, 7, 3, 4, 4, 4, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1 };

  int output[MAX_ARRAY_SIZE];
  int i;

  Compress(input, output);

  i = 0;
  while (output[i] != -1) {
    printf("%d ", output[i]);
    i++;
  }

  return 0;
}
This is a sample C assignment, so if you need help with C then contact us for help you can rely on.

ConnectTwo.c
// Gridsville.cpp : Defines the entry point for the console application.
//

#include
#include

void ConnectTwo(int maze[10][10])
{
  int i, j;
  int startI, startJ;
  int endI, endJ;
  int pathI, pathJ;
  int dI, dJ;
  int foundedPoint;

  startI = 0;
  startJ = 0;
  endI = 0;
  endJ = 0;
  foundedPoint = 0;

  for (i = 0; i < 10; i++)
  {
    for (j = 0; j < 10; j++)
    {
      if (maze[i][j] == 1)
      {
        startI = i;
        startJ = j;
        foundedPoint++;
      }

      if (maze[i][j] == 2)
      {
        endI = i;
        endJ = j; 
        foundedPoint++;
      }

      if (foundedPoint >= 2)
      {
        break;
      }
    }
  }

  if (foundedPoint < 2)
  {
    return;
  }

  dI = 0;
  dJ = 0;
  if (startI < endI)
  {
    dI = 1;
  }
  else if (startI > endI)
  {
    dI = -1;
  }

  if (startJ < endJ)
  {
    dJ = 1;
  }
  else if (startJ > endJ)
  {
    dJ = -1;
  }

  pathI = startI + dI;
  pathJ = startJ + dJ;

  while (pathI != endI || pathJ != endJ)
  {
    maze[pathI][pathJ] = 3;

    if (pathI == endI && dI != 0)
    {
      dI = 0;
    }

    if (pathJ == endJ && dJ != 0)
    {
      dJ = 0;
    }

    pathI = pathI + dI;
    pathJ = pathJ + dJ;
  }
}

int main()
{
  int i, j;
  int map[10][10] = {
    { 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
    { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
    { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
    { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
    { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
    { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
    { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
    { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
    { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
    { 0, 0, 0, 2, 0, 0, 0, 0, 0, 0 },
  };

  ConnectTwo(map);

  printf("\n");
  for (i = 0; i < 10; i++)
  {
    for (j = 0; j < 10; j++)
    {
      printf("%d", map[i][j]);      
    }
    printf("\n");
  }

  return 0;
}
For all your C project help that you need, you won’t find a better place.

DayTrader.c
// Gridsville.cpp : Defines the entry point for the console application.
//

#include
#include

void DayTrader(int *prices, int numPrices, int *bestRun, int* bestRunIndex)
{
  int i;
  int currentRun;
  int currentRunIndex;

  *bestRun = 1;
  *bestRunIndex = 0;

  currentRun = 0;
  currentRunIndex = 0;

  for (i = 1; i < numPrices; i++)
  {
    if (prices[i] > prices[i- 1])
    {
      currentRun++; // increase current run size
    }
    else
    {
      if (currentRun > *bestRun)
      {
        *bestRun = currentRun;
        *bestRunIndex = currentRunIndex;
      }

      // initialize next run
      currentRun = 0;
      currentRunIndex = i;
    }
  }

  if (currentRun > *bestRun)
  {
    *bestRun = currentRun;
    *bestRunIndex = currentRunIndex;
  }
}

int main()
{
  int pricesA[15] = {59, 60, 55, 23, 42, 44, 48, 50, 43, 45, 43, 44, 47, 51, 52};
  int pricesB[10] = {1, 2, 3, 3, 3, 4, 3, 4, 5, 6};
  int pricesC[10] = {123, 120, 118, 119, 121, 126, 127, 139, 129, 132};

  int bestRun, bestRunIndex;

  DayTrader(pricesA, 15, &bestRun, &bestRunIndex);
  printf("Best run = %d, best run index = %d\n", bestRun, bestRunIndex);

  DayTrader(pricesB, 10, &bestRun, &bestRunIndex);
  printf("Best run = %d, best run index = %d\n", bestRun, bestRunIndex);

  DayTrader(pricesC, 10, &bestRun, &bestRunIndex);
  printf("Best run = %d, best run index = %d\n", bestRun, bestRunIndex);

  return 0;
}

Index:

  • compress.c
  • ConnectTwo.c
  • DayTrader.c

You may contact us to deliver the C homework help that you need.