█████████ ████ ███░░░░░███ ░░███ ███ ░░░ ██████ ███████ ██████ ██████ ░███ ███░░███ ███░░███ ███░░███ ███░░███ ░███ ░███ ░███░███ ░███ ░███████ ░███ ░███ ░░███ ███░███ ░███░███ ░███ ░███░░░ ░███ ░███ ░░█████████ ░░██████ ░░████████░░██████ ░░██████ ░░░░░░░░░ ░░░░░░ ░░░░░░░░ ░░░░░░ ░░░░░░

Envío 3540

Problema 0x25 - Suma de un subarreglo grande

  • Autor: toroduque
  • Fecha: 2021-03-21 09:34:36 UTC (Hace más de 3 años)
Caso # Resultado Tiempo Memoria
#1
Error de compilación
                      main.c:1:7: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
const readline = require('readline');
~~~~~ ^
main.c:1:18: warning: implicit declaration of function 'require' is invalid in C99 [-Wimplicit-function-declaration]
const readline = require('readline');
                 ^
main.c:1:26: warning: multi-character character constant [-Wmultichar]
const readline = require('readline');
                         ^
main.c:1:26: warning: character constant too long for its type
main.c:1:18: error: initializer element is not a compile-time constant
const readline = require('readline');
                 ^~~~~~~~~~~~~~~~~~~
main.c:2:7: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
const rl = readline.createInterface({
~~~~~ ^
main.c:2:20: error: member reference base type 'const int' is not a structure or union
const rl = readline.createInterface({
           ~~~~~~~~^~~~~~~~~~~~~~~~
main.c:2:37: error: expected expression
const rl = readline.createInterface({
                                    ^
main.c:7:1: error: unknown type name 'let'
let lineCounter = 0;
^
main.c:8:1: error: unknown type name 'let'
let subTotalsArray;
^
main.c:10:1: error: unknown type name 'function'
function sumSubTotals(initialArray) {
^
main.c:11:3: error: use of undeclared identifier 'let'
  let totalsArray = []
  ^
main.c:13:7: error: use of undeclared identifier 'let'
  for(let i = 0; i < initialArray.length; i++)
      ^
main.c:13:34: error: member reference base type 'int' is not a structure or union
  for(let i = 0; i < initialArray.length; i++)
                     ~~~~~~~~~~~~^~~~~~~
main.c:13:18: error: use of undeclared identifier 'i'
  for(let i = 0; i < initialArray.length; i++)
                 ^
main.c:13:43: error: use of undeclared identifier 'i'
  for(let i = 0; i < initialArray.length; i++)
                                          ^
main.c:15:5: error: use of undeclared identifier 'currentSum'
    currentSum = currentSum + i
    ^
main.c:15:18: error: use of undeclared identifier 'currentSum'
    currentSum = currentSum + i
                 ^
main.c:15:31: error: use of undeclared identifier 'i'
    currentSum = currentSum + i
                              ^
main.c:19:10: error: use of undeclared identifier 'totalsArray'
  return totalsArray
         ^
main.c:22:1: error: unknown type name 'function'
function sumSubArray(fromIndex, toIndex){
^
main.c:23:9: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
  const fromTotal = subTotalsArray[fromIndex - 1];
  ~~~~~ ^
main.c:24:9: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
  const toTotal = subTotalsArray[toIndex]
  ~~~~~ ^
main.c:25:29: error: expected ';' at end of declaration
  return toTotal - fromTotal
                            ^
                            ;
main.c:28:1: error: unknown type name 'rl'
rl.on("line", (line) => {
^
main.c:28:3: error: expected identifier or '('
rl.on("line", (line) => {
  ^
7 warnings and 19 errors generated.

                    
#2
Error de compilación
                      main.c:1:7: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
const readline = require('readline');
~~~~~ ^
main.c:1:18: warning: implicit declaration of function 'require' is invalid in C99 [-Wimplicit-function-declaration]
const readline = require('readline');
                 ^
main.c:1:26: warning: multi-character character constant [-Wmultichar]
const readline = require('readline');
                         ^
main.c:1:26: warning: character constant too long for its type
main.c:1:18: error: initializer element is not a compile-time constant
const readline = require('readline');
                 ^~~~~~~~~~~~~~~~~~~
main.c:2:7: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
const rl = readline.createInterface({
~~~~~ ^
main.c:2:20: error: member reference base type 'const int' is not a structure or union
const rl = readline.createInterface({
           ~~~~~~~~^~~~~~~~~~~~~~~~
main.c:2:37: error: expected expression
const rl = readline.createInterface({
                                    ^
main.c:7:1: error: unknown type name 'let'
let lineCounter = 0;
^
main.c:8:1: error: unknown type name 'let'
let subTotalsArray;
^
main.c:10:1: error: unknown type name 'function'
function sumSubTotals(initialArray) {
^
main.c:11:3: error: use of undeclared identifier 'let'
  let totalsArray = []
  ^
main.c:13:7: error: use of undeclared identifier 'let'
  for(let i = 0; i < initialArray.length; i++)
      ^
main.c:13:34: error: member reference base type 'int' is not a structure or union
  for(let i = 0; i < initialArray.length; i++)
                     ~~~~~~~~~~~~^~~~~~~
main.c:13:18: error: use of undeclared identifier 'i'
  for(let i = 0; i < initialArray.length; i++)
                 ^
main.c:13:43: error: use of undeclared identifier 'i'
  for(let i = 0; i < initialArray.length; i++)
                                          ^
main.c:15:5: error: use of undeclared identifier 'currentSum'
    currentSum = currentSum + i
    ^
main.c:15:18: error: use of undeclared identifier 'currentSum'
    currentSum = currentSum + i
                 ^
main.c:15:31: error: use of undeclared identifier 'i'
    currentSum = currentSum + i
                              ^
main.c:19:10: error: use of undeclared identifier 'totalsArray'
  return totalsArray
         ^
main.c:22:1: error: unknown type name 'function'
function sumSubArray(fromIndex, toIndex){
^
main.c:23:9: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
  const fromTotal = subTotalsArray[fromIndex - 1];
  ~~~~~ ^
main.c:24:9: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
  const toTotal = subTotalsArray[toIndex]
  ~~~~~ ^
main.c:25:29: error: expected ';' at end of declaration
  return toTotal - fromTotal
                            ^
                            ;
main.c:28:1: error: unknown type name 'rl'
rl.on("line", (line) => {
^
main.c:28:3: error: expected identifier or '('
rl.on("line", (line) => {
  ^
7 warnings and 19 errors generated.

                    
#3
Error de compilación
                      main.c:1:7: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
const readline = require('readline');
~~~~~ ^
main.c:1:18: warning: implicit declaration of function 'require' is invalid in C99 [-Wimplicit-function-declaration]
const readline = require('readline');
                 ^
main.c:1:26: warning: multi-character character constant [-Wmultichar]
const readline = require('readline');
                         ^
main.c:1:26: warning: character constant too long for its type
main.c:1:18: error: initializer element is not a compile-time constant
const readline = require('readline');
                 ^~~~~~~~~~~~~~~~~~~
main.c:2:7: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
const rl = readline.createInterface({
~~~~~ ^
main.c:2:20: error: member reference base type 'const int' is not a structure or union
const rl = readline.createInterface({
           ~~~~~~~~^~~~~~~~~~~~~~~~
main.c:2:37: error: expected expression
const rl = readline.createInterface({
                                    ^
main.c:7:1: error: unknown type name 'let'
let lineCounter = 0;
^
main.c:8:1: error: unknown type name 'let'
let subTotalsArray;
^
main.c:10:1: error: unknown type name 'function'
function sumSubTotals(initialArray) {
^
main.c:11:3: error: use of undeclared identifier 'let'
  let totalsArray = []
  ^
main.c:13:7: error: use of undeclared identifier 'let'
  for(let i = 0; i < initialArray.length; i++)
      ^
main.c:13:34: error: member reference base type 'int' is not a structure or union
  for(let i = 0; i < initialArray.length; i++)
                     ~~~~~~~~~~~~^~~~~~~
main.c:13:18: error: use of undeclared identifier 'i'
  for(let i = 0; i < initialArray.length; i++)
                 ^
main.c:13:43: error: use of undeclared identifier 'i'
  for(let i = 0; i < initialArray.length; i++)
                                          ^
main.c:15:5: error: use of undeclared identifier 'currentSum'
    currentSum = currentSum + i
    ^
main.c:15:18: error: use of undeclared identifier 'currentSum'
    currentSum = currentSum + i
                 ^
main.c:15:31: error: use of undeclared identifier 'i'
    currentSum = currentSum + i
                              ^
main.c:19:10: error: use of undeclared identifier 'totalsArray'
  return totalsArray
         ^
main.c:22:1: error: unknown type name 'function'
function sumSubArray(fromIndex, toIndex){
^
main.c:23:9: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
  const fromTotal = subTotalsArray[fromIndex - 1];
  ~~~~~ ^
main.c:24:9: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
  const toTotal = subTotalsArray[toIndex]
  ~~~~~ ^
main.c:25:29: error: expected ';' at end of declaration
  return toTotal - fromTotal
                            ^
                            ;
main.c:28:1: error: unknown type name 'rl'
rl.on("line", (line) => {
^
main.c:28:3: error: expected identifier or '('
rl.on("line", (line) => {
  ^
7 warnings and 19 errors generated.

                    
#4
Error de compilación
                      main.c:1:7: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
const readline = require('readline');
~~~~~ ^
main.c:1:18: warning: implicit declaration of function 'require' is invalid in C99 [-Wimplicit-function-declaration]
const readline = require('readline');
                 ^
main.c:1:26: warning: multi-character character constant [-Wmultichar]
const readline = require('readline');
                         ^
main.c:1:26: warning: character constant too long for its type
main.c:1:18: error: initializer element is not a compile-time constant
const readline = require('readline');
                 ^~~~~~~~~~~~~~~~~~~
main.c:2:7: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
const rl = readline.createInterface({
~~~~~ ^
main.c:2:20: error: member reference base type 'const int' is not a structure or union
const rl = readline.createInterface({
           ~~~~~~~~^~~~~~~~~~~~~~~~
main.c:2:37: error: expected expression
const rl = readline.createInterface({
                                    ^
main.c:7:1: error: unknown type name 'let'
let lineCounter = 0;
^
main.c:8:1: error: unknown type name 'let'
let subTotalsArray;
^
main.c:10:1: error: unknown type name 'function'
function sumSubTotals(initialArray) {
^
main.c:11:3: error: use of undeclared identifier 'let'
  let totalsArray = []
  ^
main.c:13:7: error: use of undeclared identifier 'let'
  for(let i = 0; i < initialArray.length; i++)
      ^
main.c:13:34: error: member reference base type 'int' is not a structure or union
  for(let i = 0; i < initialArray.length; i++)
                     ~~~~~~~~~~~~^~~~~~~
main.c:13:18: error: use of undeclared identifier 'i'
  for(let i = 0; i < initialArray.length; i++)
                 ^
main.c:13:43: error: use of undeclared identifier 'i'
  for(let i = 0; i < initialArray.length; i++)
                                          ^
main.c:15:5: error: use of undeclared identifier 'currentSum'
    currentSum = currentSum + i
    ^
main.c:15:18: error: use of undeclared identifier 'currentSum'
    currentSum = currentSum + i
                 ^
main.c:15:31: error: use of undeclared identifier 'i'
    currentSum = currentSum + i
                              ^
main.c:19:10: error: use of undeclared identifier 'totalsArray'
  return totalsArray
         ^
main.c:22:1: error: unknown type name 'function'
function sumSubArray(fromIndex, toIndex){
^
main.c:23:9: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
  const fromTotal = subTotalsArray[fromIndex - 1];
  ~~~~~ ^
main.c:24:9: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
  const toTotal = subTotalsArray[toIndex]
  ~~~~~ ^
main.c:25:29: error: expected ';' at end of declaration
  return toTotal - fromTotal
                            ^
                            ;
main.c:28:1: error: unknown type name 'rl'
rl.on("line", (line) => {
^
main.c:28:3: error: expected identifier or '('
rl.on("line", (line) => {
  ^
7 warnings and 19 errors generated.

                    
#5
Error de compilación
                      main.c:1:7: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
const readline = require('readline');
~~~~~ ^
main.c:1:18: warning: implicit declaration of function 'require' is invalid in C99 [-Wimplicit-function-declaration]
const readline = require('readline');
                 ^
main.c:1:26: warning: multi-character character constant [-Wmultichar]
const readline = require('readline');
                         ^
main.c:1:26: warning: character constant too long for its type
main.c:1:18: error: initializer element is not a compile-time constant
const readline = require('readline');
                 ^~~~~~~~~~~~~~~~~~~
main.c:2:7: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
const rl = readline.createInterface({
~~~~~ ^
main.c:2:20: error: member reference base type 'const int' is not a structure or union
const rl = readline.createInterface({
           ~~~~~~~~^~~~~~~~~~~~~~~~
main.c:2:37: error: expected expression
const rl = readline.createInterface({
                                    ^
main.c:7:1: error: unknown type name 'let'
let lineCounter = 0;
^
main.c:8:1: error: unknown type name 'let'
let subTotalsArray;
^
main.c:10:1: error: unknown type name 'function'
function sumSubTotals(initialArray) {
^
main.c:11:3: error: use of undeclared identifier 'let'
  let totalsArray = []
  ^
main.c:13:7: error: use of undeclared identifier 'let'
  for(let i = 0; i < initialArray.length; i++)
      ^
main.c:13:34: error: member reference base type 'int' is not a structure or union
  for(let i = 0; i < initialArray.length; i++)
                     ~~~~~~~~~~~~^~~~~~~
main.c:13:18: error: use of undeclared identifier 'i'
  for(let i = 0; i < initialArray.length; i++)
                 ^
main.c:13:43: error: use of undeclared identifier 'i'
  for(let i = 0; i < initialArray.length; i++)
                                          ^
main.c:15:5: error: use of undeclared identifier 'currentSum'
    currentSum = currentSum + i
    ^
main.c:15:18: error: use of undeclared identifier 'currentSum'
    currentSum = currentSum + i
                 ^
main.c:15:31: error: use of undeclared identifier 'i'
    currentSum = currentSum + i
                              ^
main.c:19:10: error: use of undeclared identifier 'totalsArray'
  return totalsArray
         ^
main.c:22:1: error: unknown type name 'function'
function sumSubArray(fromIndex, toIndex){
^
main.c:23:9: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
  const fromTotal = subTotalsArray[fromIndex - 1];
  ~~~~~ ^
main.c:24:9: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
  const toTotal = subTotalsArray[toIndex]
  ~~~~~ ^
main.c:25:29: error: expected ';' at end of declaration
  return toTotal - fromTotal
                            ^
                            ;
main.c:28:1: error: unknown type name 'rl'
rl.on("line", (line) => {
^
main.c:28:3: error: expected identifier or '('
rl.on("line", (line) => {
  ^
7 warnings and 19 errors generated.

                    
#6
Error de compilación
                      main.c:1:7: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
const readline = require('readline');
~~~~~ ^
main.c:1:18: warning: implicit declaration of function 'require' is invalid in C99 [-Wimplicit-function-declaration]
const readline = require('readline');
                 ^
main.c:1:26: warning: multi-character character constant [-Wmultichar]
const readline = require('readline');
                         ^
main.c:1:26: warning: character constant too long for its type
main.c:1:18: error: initializer element is not a compile-time constant
const readline = require('readline');
                 ^~~~~~~~~~~~~~~~~~~
main.c:2:7: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
const rl = readline.createInterface({
~~~~~ ^
main.c:2:20: error: member reference base type 'const int' is not a structure or union
const rl = readline.createInterface({
           ~~~~~~~~^~~~~~~~~~~~~~~~
main.c:2:37: error: expected expression
const rl = readline.createInterface({
                                    ^
main.c:7:1: error: unknown type name 'let'
let lineCounter = 0;
^
main.c:8:1: error: unknown type name 'let'
let subTotalsArray;
^
main.c:10:1: error: unknown type name 'function'
function sumSubTotals(initialArray) {
^
main.c:11:3: error: use of undeclared identifier 'let'
  let totalsArray = []
  ^
main.c:13:7: error: use of undeclared identifier 'let'
  for(let i = 0; i < initialArray.length; i++)
      ^
main.c:13:34: error: member reference base type 'int' is not a structure or union
  for(let i = 0; i < initialArray.length; i++)
                     ~~~~~~~~~~~~^~~~~~~
main.c:13:18: error: use of undeclared identifier 'i'
  for(let i = 0; i < initialArray.length; i++)
                 ^
main.c:13:43: error: use of undeclared identifier 'i'
  for(let i = 0; i < initialArray.length; i++)
                                          ^
main.c:15:5: error: use of undeclared identifier 'currentSum'
    currentSum = currentSum + i
    ^
main.c:15:18: error: use of undeclared identifier 'currentSum'
    currentSum = currentSum + i
                 ^
main.c:15:31: error: use of undeclared identifier 'i'
    currentSum = currentSum + i
                              ^
main.c:19:10: error: use of undeclared identifier 'totalsArray'
  return totalsArray
         ^
main.c:22:1: error: unknown type name 'function'
function sumSubArray(fromIndex, toIndex){
^
main.c:23:9: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
  const fromTotal = subTotalsArray[fromIndex - 1];
  ~~~~~ ^
main.c:24:9: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
  const toTotal = subTotalsArray[toIndex]
  ~~~~~ ^
main.c:25:29: error: expected ';' at end of declaration
  return toTotal - fromTotal
                            ^
                            ;
main.c:28:1: error: unknown type name 'rl'
rl.on("line", (line) => {
^
main.c:28:3: error: expected identifier or '('
rl.on("line", (line) => {
  ^
7 warnings and 19 errors generated.

                    
#7
Error de compilación
                      main.c:1:7: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
const readline = require('readline');
~~~~~ ^
main.c:1:18: warning: implicit declaration of function 'require' is invalid in C99 [-Wimplicit-function-declaration]
const readline = require('readline');
                 ^
main.c:1:26: warning: multi-character character constant [-Wmultichar]
const readline = require('readline');
                         ^
main.c:1:26: warning: character constant too long for its type
main.c:1:18: error: initializer element is not a compile-time constant
const readline = require('readline');
                 ^~~~~~~~~~~~~~~~~~~
main.c:2:7: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
const rl = readline.createInterface({
~~~~~ ^
main.c:2:20: error: member reference base type 'const int' is not a structure or union
const rl = readline.createInterface({
           ~~~~~~~~^~~~~~~~~~~~~~~~
main.c:2:37: error: expected expression
const rl = readline.createInterface({
                                    ^
main.c:7:1: error: unknown type name 'let'
let lineCounter = 0;
^
main.c:8:1: error: unknown type name 'let'
let subTotalsArray;
^
main.c:10:1: error: unknown type name 'function'
function sumSubTotals(initialArray) {
^
main.c:11:3: error: use of undeclared identifier 'let'
  let totalsArray = []
  ^
main.c:13:7: error: use of undeclared identifier 'let'
  for(let i = 0; i < initialArray.length; i++)
      ^
main.c:13:34: error: member reference base type 'int' is not a structure or union
  for(let i = 0; i < initialArray.length; i++)
                     ~~~~~~~~~~~~^~~~~~~
main.c:13:18: error: use of undeclared identifier 'i'
  for(let i = 0; i < initialArray.length; i++)
                 ^
main.c:13:43: error: use of undeclared identifier 'i'
  for(let i = 0; i < initialArray.length; i++)
                                          ^
main.c:15:5: error: use of undeclared identifier 'currentSum'
    currentSum = currentSum + i
    ^
main.c:15:18: error: use of undeclared identifier 'currentSum'
    currentSum = currentSum + i
                 ^
main.c:15:31: error: use of undeclared identifier 'i'
    currentSum = currentSum + i
                              ^
main.c:19:10: error: use of undeclared identifier 'totalsArray'
  return totalsArray
         ^
main.c:22:1: error: unknown type name 'function'
function sumSubArray(fromIndex, toIndex){
^
main.c:23:9: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
  const fromTotal = subTotalsArray[fromIndex - 1];
  ~~~~~ ^
main.c:24:9: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
  const toTotal = subTotalsArray[toIndex]
  ~~~~~ ^
main.c:25:29: error: expected ';' at end of declaration
  return toTotal - fromTotal
                            ^
                            ;
main.c:28:1: error: unknown type name 'rl'
rl.on("line", (line) => {
^
main.c:28:3: error: expected identifier or '('
rl.on("line", (line) => {
  ^
7 warnings and 19 errors generated.

                    
#8
Error de compilación
                      main.c:1:7: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
const readline = require('readline');
~~~~~ ^
main.c:1:18: warning: implicit declaration of function 'require' is invalid in C99 [-Wimplicit-function-declaration]
const readline = require('readline');
                 ^
main.c:1:26: warning: multi-character character constant [-Wmultichar]
const readline = require('readline');
                         ^
main.c:1:26: warning: character constant too long for its type
main.c:1:18: error: initializer element is not a compile-time constant
const readline = require('readline');
                 ^~~~~~~~~~~~~~~~~~~
main.c:2:7: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
const rl = readline.createInterface({
~~~~~ ^
main.c:2:20: error: member reference base type 'const int' is not a structure or union
const rl = readline.createInterface({
           ~~~~~~~~^~~~~~~~~~~~~~~~
main.c:2:37: error: expected expression
const rl = readline.createInterface({
                                    ^
main.c:7:1: error: unknown type name 'let'
let lineCounter = 0;
^
main.c:8:1: error: unknown type name 'let'
let subTotalsArray;
^
main.c:10:1: error: unknown type name 'function'
function sumSubTotals(initialArray) {
^
main.c:11:3: error: use of undeclared identifier 'let'
  let totalsArray = []
  ^
main.c:13:7: error: use of undeclared identifier 'let'
  for(let i = 0; i < initialArray.length; i++)
      ^
main.c:13:34: error: member reference base type 'int' is not a structure or union
  for(let i = 0; i < initialArray.length; i++)
                     ~~~~~~~~~~~~^~~~~~~
main.c:13:18: error: use of undeclared identifier 'i'
  for(let i = 0; i < initialArray.length; i++)
                 ^
main.c:13:43: error: use of undeclared identifier 'i'
  for(let i = 0; i < initialArray.length; i++)
                                          ^
main.c:15:5: error: use of undeclared identifier 'currentSum'
    currentSum = currentSum + i
    ^
main.c:15:18: error: use of undeclared identifier 'currentSum'
    currentSum = currentSum + i
                 ^
main.c:15:31: error: use of undeclared identifier 'i'
    currentSum = currentSum + i
                              ^
main.c:19:10: error: use of undeclared identifier 'totalsArray'
  return totalsArray
         ^
main.c:22:1: error: unknown type name 'function'
function sumSubArray(fromIndex, toIndex){
^
main.c:23:9: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
  const fromTotal = subTotalsArray[fromIndex - 1];
  ~~~~~ ^
main.c:24:9: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
  const toTotal = subTotalsArray[toIndex]
  ~~~~~ ^
main.c:25:29: error: expected ';' at end of declaration
  return toTotal - fromTotal
                            ^
                            ;
main.c:28:1: error: unknown type name 'rl'
rl.on("line", (line) => {
^
main.c:28:3: error: expected identifier or '('
rl.on("line", (line) => {
  ^
7 warnings and 19 errors generated.

                    
#9
Error de compilación
                      main.c:1:7: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
const readline = require('readline');
~~~~~ ^
main.c:1:18: warning: implicit declaration of function 'require' is invalid in C99 [-Wimplicit-function-declaration]
const readline = require('readline');
                 ^
main.c:1:26: warning: multi-character character constant [-Wmultichar]
const readline = require('readline');
                         ^
main.c:1:26: warning: character constant too long for its type
main.c:1:18: error: initializer element is not a compile-time constant
const readline = require('readline');
                 ^~~~~~~~~~~~~~~~~~~
main.c:2:7: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
const rl = readline.createInterface({
~~~~~ ^
main.c:2:20: error: member reference base type 'const int' is not a structure or union
const rl = readline.createInterface({
           ~~~~~~~~^~~~~~~~~~~~~~~~
main.c:2:37: error: expected expression
const rl = readline.createInterface({
                                    ^
main.c:7:1: error: unknown type name 'let'
let lineCounter = 0;
^
main.c:8:1: error: unknown type name 'let'
let subTotalsArray;
^
main.c:10:1: error: unknown type name 'function'
function sumSubTotals(initialArray) {
^
main.c:11:3: error: use of undeclared identifier 'let'
  let totalsArray = []
  ^
main.c:13:7: error: use of undeclared identifier 'let'
  for(let i = 0; i < initialArray.length; i++)
      ^
main.c:13:34: error: member reference base type 'int' is not a structure or union
  for(let i = 0; i < initialArray.length; i++)
                     ~~~~~~~~~~~~^~~~~~~
main.c:13:18: error: use of undeclared identifier 'i'
  for(let i = 0; i < initialArray.length; i++)
                 ^
main.c:13:43: error: use of undeclared identifier 'i'
  for(let i = 0; i < initialArray.length; i++)
                                          ^
main.c:15:5: error: use of undeclared identifier 'currentSum'
    currentSum = currentSum + i
    ^
main.c:15:18: error: use of undeclared identifier 'currentSum'
    currentSum = currentSum + i
                 ^
main.c:15:31: error: use of undeclared identifier 'i'
    currentSum = currentSum + i
                              ^
main.c:19:10: error: use of undeclared identifier 'totalsArray'
  return totalsArray
         ^
main.c:22:1: error: unknown type name 'function'
function sumSubArray(fromIndex, toIndex){
^
main.c:23:9: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
  const fromTotal = subTotalsArray[fromIndex - 1];
  ~~~~~ ^
main.c:24:9: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
  const toTotal = subTotalsArray[toIndex]
  ~~~~~ ^
main.c:25:29: error: expected ';' at end of declaration
  return toTotal - fromTotal
                            ^
                            ;
main.c:28:1: error: unknown type name 'rl'
rl.on("line", (line) => {
^
main.c:28:3: error: expected identifier or '('
rl.on("line", (line) => {
  ^
7 warnings and 19 errors generated.

                    
#10
Error de compilación
                      main.c:1:7: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
const readline = require('readline');
~~~~~ ^
main.c:1:18: warning: implicit declaration of function 'require' is invalid in C99 [-Wimplicit-function-declaration]
const readline = require('readline');
                 ^
main.c:1:26: warning: multi-character character constant [-Wmultichar]
const readline = require('readline');
                         ^
main.c:1:26: warning: character constant too long for its type
main.c:1:18: error: initializer element is not a compile-time constant
const readline = require('readline');
                 ^~~~~~~~~~~~~~~~~~~
main.c:2:7: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
const rl = readline.createInterface({
~~~~~ ^
main.c:2:20: error: member reference base type 'const int' is not a structure or union
const rl = readline.createInterface({
           ~~~~~~~~^~~~~~~~~~~~~~~~
main.c:2:37: error: expected expression
const rl = readline.createInterface({
                                    ^
main.c:7:1: error: unknown type name 'let'
let lineCounter = 0;
^
main.c:8:1: error: unknown type name 'let'
let subTotalsArray;
^
main.c:10:1: error: unknown type name 'function'
function sumSubTotals(initialArray) {
^
main.c:11:3: error: use of undeclared identifier 'let'
  let totalsArray = []
  ^
main.c:13:7: error: use of undeclared identifier 'let'
  for(let i = 0; i < initialArray.length; i++)
      ^
main.c:13:34: error: member reference base type 'int' is not a structure or union
  for(let i = 0; i < initialArray.length; i++)
                     ~~~~~~~~~~~~^~~~~~~
main.c:13:18: error: use of undeclared identifier 'i'
  for(let i = 0; i < initialArray.length; i++)
                 ^
main.c:13:43: error: use of undeclared identifier 'i'
  for(let i = 0; i < initialArray.length; i++)
                                          ^
main.c:15:5: error: use of undeclared identifier 'currentSum'
    currentSum = currentSum + i
    ^
main.c:15:18: error: use of undeclared identifier 'currentSum'
    currentSum = currentSum + i
                 ^
main.c:15:31: error: use of undeclared identifier 'i'
    currentSum = currentSum + i
                              ^
main.c:19:10: error: use of undeclared identifier 'totalsArray'
  return totalsArray
         ^
main.c:22:1: error: unknown type name 'function'
function sumSubArray(fromIndex, toIndex){
^
main.c:23:9: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
  const fromTotal = subTotalsArray[fromIndex - 1];
  ~~~~~ ^
main.c:24:9: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
  const toTotal = subTotalsArray[toIndex]
  ~~~~~ ^
main.c:25:29: error: expected ';' at end of declaration
  return toTotal - fromTotal
                            ^
                            ;
main.c:28:1: error: unknown type name 'rl'
rl.on("line", (line) => {
^
main.c:28:3: error: expected identifier or '('
rl.on("line", (line) => {
  ^
7 warnings and 19 errors generated.

                    
#11
Error de compilación
                      main.c:1:7: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
const readline = require('readline');
~~~~~ ^
main.c:1:18: warning: implicit declaration of function 'require' is invalid in C99 [-Wimplicit-function-declaration]
const readline = require('readline');
                 ^
main.c:1:26: warning: multi-character character constant [-Wmultichar]
const readline = require('readline');
                         ^
main.c:1:26: warning: character constant too long for its type
main.c:1:18: error: initializer element is not a compile-time constant
const readline = require('readline');
                 ^~~~~~~~~~~~~~~~~~~
main.c:2:7: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
const rl = readline.createInterface({
~~~~~ ^
main.c:2:20: error: member reference base type 'const int' is not a structure or union
const rl = readline.createInterface({
           ~~~~~~~~^~~~~~~~~~~~~~~~
main.c:2:37: error: expected expression
const rl = readline.createInterface({
                                    ^
main.c:7:1: error: unknown type name 'let'
let lineCounter = 0;
^
main.c:8:1: error: unknown type name 'let'
let subTotalsArray;
^
main.c:10:1: error: unknown type name 'function'
function sumSubTotals(initialArray) {
^
main.c:11:3: error: use of undeclared identifier 'let'
  let totalsArray = []
  ^
main.c:13:7: error: use of undeclared identifier 'let'
  for(let i = 0; i < initialArray.length; i++)
      ^
main.c:13:34: error: member reference base type 'int' is not a structure or union
  for(let i = 0; i < initialArray.length; i++)
                     ~~~~~~~~~~~~^~~~~~~
main.c:13:18: error: use of undeclared identifier 'i'
  for(let i = 0; i < initialArray.length; i++)
                 ^
main.c:13:43: error: use of undeclared identifier 'i'
  for(let i = 0; i < initialArray.length; i++)
                                          ^
main.c:15:5: error: use of undeclared identifier 'currentSum'
    currentSum = currentSum + i
    ^
main.c:15:18: error: use of undeclared identifier 'currentSum'
    currentSum = currentSum + i
                 ^
main.c:15:31: error: use of undeclared identifier 'i'
    currentSum = currentSum + i
                              ^
main.c:19:10: error: use of undeclared identifier 'totalsArray'
  return totalsArray
         ^
main.c:22:1: error: unknown type name 'function'
function sumSubArray(fromIndex, toIndex){
^
main.c:23:9: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
  const fromTotal = subTotalsArray[fromIndex - 1];
  ~~~~~ ^
main.c:24:9: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
  const toTotal = subTotalsArray[toIndex]
  ~~~~~ ^
main.c:25:29: error: expected ';' at end of declaration
  return toTotal - fromTotal
                            ^
                            ;
main.c:28:1: error: unknown type name 'rl'
rl.on("line", (line) => {
^
main.c:28:3: error: expected identifier or '('
rl.on("line", (line) => {
  ^
7 warnings and 19 errors generated.

                    
#12
Error de compilación
                      main.c:1:7: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
const readline = require('readline');
~~~~~ ^
main.c:1:18: warning: implicit declaration of function 'require' is invalid in C99 [-Wimplicit-function-declaration]
const readline = require('readline');
                 ^
main.c:1:26: warning: multi-character character constant [-Wmultichar]
const readline = require('readline');
                         ^
main.c:1:26: warning: character constant too long for its type
main.c:1:18: error: initializer element is not a compile-time constant
const readline = require('readline');
                 ^~~~~~~~~~~~~~~~~~~
main.c:2:7: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
const rl = readline.createInterface({
~~~~~ ^
main.c:2:20: error: member reference base type 'const int' is not a structure or union
const rl = readline.createInterface({
           ~~~~~~~~^~~~~~~~~~~~~~~~
main.c:2:37: error: expected expression
const rl = readline.createInterface({
                                    ^
main.c:7:1: error: unknown type name 'let'
let lineCounter = 0;
^
main.c:8:1: error: unknown type name 'let'
let subTotalsArray;
^
main.c:10:1: error: unknown type name 'function'
function sumSubTotals(initialArray) {
^
main.c:11:3: error: use of undeclared identifier 'let'
  let totalsArray = []
  ^
main.c:13:7: error: use of undeclared identifier 'let'
  for(let i = 0; i < initialArray.length; i++)
      ^
main.c:13:34: error: member reference base type 'int' is not a structure or union
  for(let i = 0; i < initialArray.length; i++)
                     ~~~~~~~~~~~~^~~~~~~
main.c:13:18: error: use of undeclared identifier 'i'
  for(let i = 0; i < initialArray.length; i++)
                 ^
main.c:13:43: error: use of undeclared identifier 'i'
  for(let i = 0; i < initialArray.length; i++)
                                          ^
main.c:15:5: error: use of undeclared identifier 'currentSum'
    currentSum = currentSum + i
    ^
main.c:15:18: error: use of undeclared identifier 'currentSum'
    currentSum = currentSum + i
                 ^
main.c:15:31: error: use of undeclared identifier 'i'
    currentSum = currentSum + i
                              ^
main.c:19:10: error: use of undeclared identifier 'totalsArray'
  return totalsArray
         ^
main.c:22:1: error: unknown type name 'function'
function sumSubArray(fromIndex, toIndex){
^
main.c:23:9: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
  const fromTotal = subTotalsArray[fromIndex - 1];
  ~~~~~ ^
main.c:24:9: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
  const toTotal = subTotalsArray[toIndex]
  ~~~~~ ^
main.c:25:29: error: expected ';' at end of declaration
  return toTotal - fromTotal
                            ^
                            ;
main.c:28:1: error: unknown type name 'rl'
rl.on("line", (line) => {
^
main.c:28:3: error: expected identifier or '('
rl.on("line", (line) => {
  ^
7 warnings and 19 errors generated.

                    
#13
Error de compilación
                      main.c:1:7: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
const readline = require('readline');
~~~~~ ^
main.c:1:18: warning: implicit declaration of function 'require' is invalid in C99 [-Wimplicit-function-declaration]
const readline = require('readline');
                 ^
main.c:1:26: warning: multi-character character constant [-Wmultichar]
const readline = require('readline');
                         ^
main.c:1:26: warning: character constant too long for its type
main.c:1:18: error: initializer element is not a compile-time constant
const readline = require('readline');
                 ^~~~~~~~~~~~~~~~~~~
main.c:2:7: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
const rl = readline.createInterface({
~~~~~ ^
main.c:2:20: error: member reference base type 'const int' is not a structure or union
const rl = readline.createInterface({
           ~~~~~~~~^~~~~~~~~~~~~~~~
main.c:2:37: error: expected expression
const rl = readline.createInterface({
                                    ^
main.c:7:1: error: unknown type name 'let'
let lineCounter = 0;
^
main.c:8:1: error: unknown type name 'let'
let subTotalsArray;
^
main.c:10:1: error: unknown type name 'function'
function sumSubTotals(initialArray) {
^
main.c:11:3: error: use of undeclared identifier 'let'
  let totalsArray = []
  ^
main.c:13:7: error: use of undeclared identifier 'let'
  for(let i = 0; i < initialArray.length; i++)
      ^
main.c:13:34: error: member reference base type 'int' is not a structure or union
  for(let i = 0; i < initialArray.length; i++)
                     ~~~~~~~~~~~~^~~~~~~
main.c:13:18: error: use of undeclared identifier 'i'
  for(let i = 0; i < initialArray.length; i++)
                 ^
main.c:13:43: error: use of undeclared identifier 'i'
  for(let i = 0; i < initialArray.length; i++)
                                          ^
main.c:15:5: error: use of undeclared identifier 'currentSum'
    currentSum = currentSum + i
    ^
main.c:15:18: error: use of undeclared identifier 'currentSum'
    currentSum = currentSum + i
                 ^
main.c:15:31: error: use of undeclared identifier 'i'
    currentSum = currentSum + i
                              ^
main.c:19:10: error: use of undeclared identifier 'totalsArray'
  return totalsArray
         ^
main.c:22:1: error: unknown type name 'function'
function sumSubArray(fromIndex, toIndex){
^
main.c:23:9: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
  const fromTotal = subTotalsArray[fromIndex - 1];
  ~~~~~ ^
main.c:24:9: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
  const toTotal = subTotalsArray[toIndex]
  ~~~~~ ^
main.c:25:29: error: expected ';' at end of declaration
  return toTotal - fromTotal
                            ^
                            ;
main.c:28:1: error: unknown type name 'rl'
rl.on("line", (line) => {
^
main.c:28:3: error: expected identifier or '('
rl.on("line", (line) => {
  ^
7 warnings and 19 errors generated.

                    
#14
Error de compilación
                      main.c:1:7: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
const readline = require('readline');
~~~~~ ^
main.c:1:18: warning: implicit declaration of function 'require' is invalid in C99 [-Wimplicit-function-declaration]
const readline = require('readline');
                 ^
main.c:1:26: warning: multi-character character constant [-Wmultichar]
const readline = require('readline');
                         ^
main.c:1:26: warning: character constant too long for its type
main.c:1:18: error: initializer element is not a compile-time constant
const readline = require('readline');
                 ^~~~~~~~~~~~~~~~~~~
main.c:2:7: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
const rl = readline.createInterface({
~~~~~ ^
main.c:2:20: error: member reference base type 'const int' is not a structure or union
const rl = readline.createInterface({
           ~~~~~~~~^~~~~~~~~~~~~~~~
main.c:2:37: error: expected expression
const rl = readline.createInterface({
                                    ^
main.c:7:1: error: unknown type name 'let'
let lineCounter = 0;
^
main.c:8:1: error: unknown type name 'let'
let subTotalsArray;
^
main.c:10:1: error: unknown type name 'function'
function sumSubTotals(initialArray) {
^
main.c:11:3: error: use of undeclared identifier 'let'
  let totalsArray = []
  ^
main.c:13:7: error: use of undeclared identifier 'let'
  for(let i = 0; i < initialArray.length; i++)
      ^
main.c:13:34: error: member reference base type 'int' is not a structure or union
  for(let i = 0; i < initialArray.length; i++)
                     ~~~~~~~~~~~~^~~~~~~
main.c:13:18: error: use of undeclared identifier 'i'
  for(let i = 0; i < initialArray.length; i++)
                 ^
main.c:13:43: error: use of undeclared identifier 'i'
  for(let i = 0; i < initialArray.length; i++)
                                          ^
main.c:15:5: error: use of undeclared identifier 'currentSum'
    currentSum = currentSum + i
    ^
main.c:15:18: error: use of undeclared identifier 'currentSum'
    currentSum = currentSum + i
                 ^
main.c:15:31: error: use of undeclared identifier 'i'
    currentSum = currentSum + i
                              ^
main.c:19:10: error: use of undeclared identifier 'totalsArray'
  return totalsArray
         ^
main.c:22:1: error: unknown type name 'function'
function sumSubArray(fromIndex, toIndex){
^
main.c:23:9: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
  const fromTotal = subTotalsArray[fromIndex - 1];
  ~~~~~ ^
main.c:24:9: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
  const toTotal = subTotalsArray[toIndex]
  ~~~~~ ^
main.c:25:29: error: expected ';' at end of declaration
  return toTotal - fromTotal
                            ^
                            ;
main.c:28:1: error: unknown type name 'rl'
rl.on("line", (line) => {
^
main.c:28:3: error: expected identifier or '('
rl.on("line", (line) => {
  ^
7 warnings and 19 errors generated.

                    
Puntos totales: 0 / 100

Código

const readline = require('readline');
const rl = readline.createInterface({
  input: process.stdin,
  output: process.stdout
});

let lineCounter = 0;
let subTotalsArray;

function sumSubTotals(initialArray) {
  let totalsArray = []
  let currentSum = 0;
  for(let i = 0; i < initialArray.length; i++)
  {
    currentSum = currentSum + i
    totalsArray.push(currentSum)
  }

  return totalsArray
}

function sumSubArray(fromIndex, toIndex){
  const fromTotal = subTotalsArray[fromIndex - 1];
  const toTotal = subTotalsArray[toIndex]
  return toTotal - fromTotal
}

rl.on("line", (line) => {
 lineCounter++;
 if (lineCounter === 2) {
  // Run the initial algorithm
  const initialArray = line.split(" ").map(Number);
  subTotalsArray = sumSubTotals(initialArray)
 }

 if (lineCounter > 3) {
   // these are the inputs Q & P
   const [Q, P] = line.split(" ").map(Number);
   console.log(sumSubArray(Q, P))
 }
})