fork download
  1. #include <stdio.h>
  2. #include <string.h>
  3. #include <ctype.h>
  4. #include <stdlib.h>
  5.  
  6. int processArray(int array[], int len) {
  7. /*
  8.   * Do not make any changes outside this function.
  9.   *
  10.   * Modify this function to process `array` as indicated
  11.   * in the question. At the end, return the length of the
  12.   * array.
  13.   *
  14.   * Do not print anything in this function
  15.   * Do not write anything to the standard output
  16.   *
  17.   * Submit this entire program (not just this function)
  18.   * as your answer
  19.   */
  20. int n,count=0,i;
  21.  
  22. for(i=0;i<len;i++)
  23.  
  24. {
  25. if(array[i]>10 && array[i]/10==6)
  26. {
  27. //if(array[i]%10== 6)
  28. //count = (array[i]%10==6);
  29.  
  30. i++;
  31.  
  32. }
  33. }
  34. return len;
  35. }
  36.  
  37. int main() {
  38. int *array;
  39. int len = 0, maxsize = 1024, i, input, new_len;
  40. int result;
  41. array = (int *)malloc(maxsize*sizeof(int));
  42. while(scanf("%d", &input) == 1) {
  43. if (input < 0) break; /* Stop when a negative number is entered */
  44. array[len++] = input;
  45. if (len == maxsize) { /* array is full. increase size */
  46. maxsize *= 2;
  47. array = (int *)realloc(array, maxsize*sizeof(int));
  48. }
  49. }
  50. new_len = processArray(array, len);
  51. for(i=0; i<new_len; i++)
  52. printf("%d\n", array[i]);
  53. return 0;
  54. }
  55.  
Success #stdin #stdout 0s 5276KB
stdin
3
26
1226
-1
stdout
3
26
1226