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

Envío 3531

Problema 0x9d - ¿Está ordenado?

  • Autor: toroduque
  • Fecha: 2021-03-21 07:48:41 UTC (Hace más de 3 años)
Caso # Resultado Tiempo Memoria
#1
Error de compilación
                      main.c:1:1: error: unknown type name 'var'
var readline = require('readline');
^
main.c:1:16: warning: implicit declaration of function 'require' is invalid in C99 [-Wimplicit-function-declaration]
var readline = require('readline');
               ^
main.c:1:24: warning: multi-character character constant [-Wmultichar]
var readline = require('readline');
                       ^
main.c:1:24: warning: character constant too long for its type
main.c:3:1: error: unknown type name 'var'
var rl = readline.createInterface({
^
main.c:3:35: error: expected expression
var rl = readline.createInterface({
                                  ^
main.c:8:1: error: unknown type name 'function'
function lineCounter(line = 0) {
^
main.c:8:22: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
function lineCounter(line = 0) {
                     ^
main.c:8:27: error: C does not support default arguments
function lineCounter(line = 0) {
                          ^ ~
main.c:12:1: error: unknown type name 'function'
function isSorted(arr) {
^
main.c:13:2: error: use of undeclared identifier 'let'
 let previousItem = Number.POSITIVE_INFINITY
 ^
main.c:23:1: error: unknown type name 'rl'
rl.on("line", function(line, lineNum = lineCounter() {
^
main.c:23:3: error: expected identifier or '('
rl.on("line", function(line, lineNum = lineCounter() {
  ^
4 warnings and 9 errors generated.

                    
#2
Error de compilación
                      main.c:1:1: error: unknown type name 'var'
var readline = require('readline');
^
main.c:1:16: warning: implicit declaration of function 'require' is invalid in C99 [-Wimplicit-function-declaration]
var readline = require('readline');
               ^
main.c:1:24: warning: multi-character character constant [-Wmultichar]
var readline = require('readline');
                       ^
main.c:1:24: warning: character constant too long for its type
main.c:3:1: error: unknown type name 'var'
var rl = readline.createInterface({
^
main.c:3:35: error: expected expression
var rl = readline.createInterface({
                                  ^
main.c:8:1: error: unknown type name 'function'
function lineCounter(line = 0) {
^
main.c:8:22: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
function lineCounter(line = 0) {
                     ^
main.c:8:27: error: C does not support default arguments
function lineCounter(line = 0) {
                          ^ ~
main.c:12:1: error: unknown type name 'function'
function isSorted(arr) {
^
main.c:13:2: error: use of undeclared identifier 'let'
 let previousItem = Number.POSITIVE_INFINITY
 ^
main.c:23:1: error: unknown type name 'rl'
rl.on("line", function(line, lineNum = lineCounter() {
^
main.c:23:3: error: expected identifier or '('
rl.on("line", function(line, lineNum = lineCounter() {
  ^
4 warnings and 9 errors generated.

                    
#3
Error de compilación
                      main.c:1:1: error: unknown type name 'var'
var readline = require('readline');
^
main.c:1:16: warning: implicit declaration of function 'require' is invalid in C99 [-Wimplicit-function-declaration]
var readline = require('readline');
               ^
main.c:1:24: warning: multi-character character constant [-Wmultichar]
var readline = require('readline');
                       ^
main.c:1:24: warning: character constant too long for its type
main.c:3:1: error: unknown type name 'var'
var rl = readline.createInterface({
^
main.c:3:35: error: expected expression
var rl = readline.createInterface({
                                  ^
main.c:8:1: error: unknown type name 'function'
function lineCounter(line = 0) {
^
main.c:8:22: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
function lineCounter(line = 0) {
                     ^
main.c:8:27: error: C does not support default arguments
function lineCounter(line = 0) {
                          ^ ~
main.c:12:1: error: unknown type name 'function'
function isSorted(arr) {
^
main.c:13:2: error: use of undeclared identifier 'let'
 let previousItem = Number.POSITIVE_INFINITY
 ^
main.c:23:1: error: unknown type name 'rl'
rl.on("line", function(line, lineNum = lineCounter() {
^
main.c:23:3: error: expected identifier or '('
rl.on("line", function(line, lineNum = lineCounter() {
  ^
4 warnings and 9 errors generated.

                    
#4
Error de compilación
                      main.c:1:1: error: unknown type name 'var'
var readline = require('readline');
^
main.c:1:16: warning: implicit declaration of function 'require' is invalid in C99 [-Wimplicit-function-declaration]
var readline = require('readline');
               ^
main.c:1:24: warning: multi-character character constant [-Wmultichar]
var readline = require('readline');
                       ^
main.c:1:24: warning: character constant too long for its type
main.c:3:1: error: unknown type name 'var'
var rl = readline.createInterface({
^
main.c:3:35: error: expected expression
var rl = readline.createInterface({
                                  ^
main.c:8:1: error: unknown type name 'function'
function lineCounter(line = 0) {
^
main.c:8:22: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
function lineCounter(line = 0) {
                     ^
main.c:8:27: error: C does not support default arguments
function lineCounter(line = 0) {
                          ^ ~
main.c:12:1: error: unknown type name 'function'
function isSorted(arr) {
^
main.c:13:2: error: use of undeclared identifier 'let'
 let previousItem = Number.POSITIVE_INFINITY
 ^
main.c:23:1: error: unknown type name 'rl'
rl.on("line", function(line, lineNum = lineCounter() {
^
main.c:23:3: error: expected identifier or '('
rl.on("line", function(line, lineNum = lineCounter() {
  ^
4 warnings and 9 errors generated.

                    
#5
Error de compilación
                      main.c:1:1: error: unknown type name 'var'
var readline = require('readline');
^
main.c:1:16: warning: implicit declaration of function 'require' is invalid in C99 [-Wimplicit-function-declaration]
var readline = require('readline');
               ^
main.c:1:24: warning: multi-character character constant [-Wmultichar]
var readline = require('readline');
                       ^
main.c:1:24: warning: character constant too long for its type
main.c:3:1: error: unknown type name 'var'
var rl = readline.createInterface({
^
main.c:3:35: error: expected expression
var rl = readline.createInterface({
                                  ^
main.c:8:1: error: unknown type name 'function'
function lineCounter(line = 0) {
^
main.c:8:22: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
function lineCounter(line = 0) {
                     ^
main.c:8:27: error: C does not support default arguments
function lineCounter(line = 0) {
                          ^ ~
main.c:12:1: error: unknown type name 'function'
function isSorted(arr) {
^
main.c:13:2: error: use of undeclared identifier 'let'
 let previousItem = Number.POSITIVE_INFINITY
 ^
main.c:23:1: error: unknown type name 'rl'
rl.on("line", function(line, lineNum = lineCounter() {
^
main.c:23:3: error: expected identifier or '('
rl.on("line", function(line, lineNum = lineCounter() {
  ^
4 warnings and 9 errors generated.

                    
#6
Error de compilación
                      main.c:1:1: error: unknown type name 'var'
var readline = require('readline');
^
main.c:1:16: warning: implicit declaration of function 'require' is invalid in C99 [-Wimplicit-function-declaration]
var readline = require('readline');
               ^
main.c:1:24: warning: multi-character character constant [-Wmultichar]
var readline = require('readline');
                       ^
main.c:1:24: warning: character constant too long for its type
main.c:3:1: error: unknown type name 'var'
var rl = readline.createInterface({
^
main.c:3:35: error: expected expression
var rl = readline.createInterface({
                                  ^
main.c:8:1: error: unknown type name 'function'
function lineCounter(line = 0) {
^
main.c:8:22: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
function lineCounter(line = 0) {
                     ^
main.c:8:27: error: C does not support default arguments
function lineCounter(line = 0) {
                          ^ ~
main.c:12:1: error: unknown type name 'function'
function isSorted(arr) {
^
main.c:13:2: error: use of undeclared identifier 'let'
 let previousItem = Number.POSITIVE_INFINITY
 ^
main.c:23:1: error: unknown type name 'rl'
rl.on("line", function(line, lineNum = lineCounter() {
^
main.c:23:3: error: expected identifier or '('
rl.on("line", function(line, lineNum = lineCounter() {
  ^
4 warnings and 9 errors generated.

                    
#7
Error de compilación
                      main.c:1:1: error: unknown type name 'var'
var readline = require('readline');
^
main.c:1:16: warning: implicit declaration of function 'require' is invalid in C99 [-Wimplicit-function-declaration]
var readline = require('readline');
               ^
main.c:1:24: warning: multi-character character constant [-Wmultichar]
var readline = require('readline');
                       ^
main.c:1:24: warning: character constant too long for its type
main.c:3:1: error: unknown type name 'var'
var rl = readline.createInterface({
^
main.c:3:35: error: expected expression
var rl = readline.createInterface({
                                  ^
main.c:8:1: error: unknown type name 'function'
function lineCounter(line = 0) {
^
main.c:8:22: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
function lineCounter(line = 0) {
                     ^
main.c:8:27: error: C does not support default arguments
function lineCounter(line = 0) {
                          ^ ~
main.c:12:1: error: unknown type name 'function'
function isSorted(arr) {
^
main.c:13:2: error: use of undeclared identifier 'let'
 let previousItem = Number.POSITIVE_INFINITY
 ^
main.c:23:1: error: unknown type name 'rl'
rl.on("line", function(line, lineNum = lineCounter() {
^
main.c:23:3: error: expected identifier or '('
rl.on("line", function(line, lineNum = lineCounter() {
  ^
4 warnings and 9 errors generated.

                    
#8
Error de compilación
                      main.c:1:1: error: unknown type name 'var'
var readline = require('readline');
^
main.c:1:16: warning: implicit declaration of function 'require' is invalid in C99 [-Wimplicit-function-declaration]
var readline = require('readline');
               ^
main.c:1:24: warning: multi-character character constant [-Wmultichar]
var readline = require('readline');
                       ^
main.c:1:24: warning: character constant too long for its type
main.c:3:1: error: unknown type name 'var'
var rl = readline.createInterface({
^
main.c:3:35: error: expected expression
var rl = readline.createInterface({
                                  ^
main.c:8:1: error: unknown type name 'function'
function lineCounter(line = 0) {
^
main.c:8:22: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
function lineCounter(line = 0) {
                     ^
main.c:8:27: error: C does not support default arguments
function lineCounter(line = 0) {
                          ^ ~
main.c:12:1: error: unknown type name 'function'
function isSorted(arr) {
^
main.c:13:2: error: use of undeclared identifier 'let'
 let previousItem = Number.POSITIVE_INFINITY
 ^
main.c:23:1: error: unknown type name 'rl'
rl.on("line", function(line, lineNum = lineCounter() {
^
main.c:23:3: error: expected identifier or '('
rl.on("line", function(line, lineNum = lineCounter() {
  ^
4 warnings and 9 errors generated.

                    
#9
Error de compilación
                      main.c:1:1: error: unknown type name 'var'
var readline = require('readline');
^
main.c:1:16: warning: implicit declaration of function 'require' is invalid in C99 [-Wimplicit-function-declaration]
var readline = require('readline');
               ^
main.c:1:24: warning: multi-character character constant [-Wmultichar]
var readline = require('readline');
                       ^
main.c:1:24: warning: character constant too long for its type
main.c:3:1: error: unknown type name 'var'
var rl = readline.createInterface({
^
main.c:3:35: error: expected expression
var rl = readline.createInterface({
                                  ^
main.c:8:1: error: unknown type name 'function'
function lineCounter(line = 0) {
^
main.c:8:22: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
function lineCounter(line = 0) {
                     ^
main.c:8:27: error: C does not support default arguments
function lineCounter(line = 0) {
                          ^ ~
main.c:12:1: error: unknown type name 'function'
function isSorted(arr) {
^
main.c:13:2: error: use of undeclared identifier 'let'
 let previousItem = Number.POSITIVE_INFINITY
 ^
main.c:23:1: error: unknown type name 'rl'
rl.on("line", function(line, lineNum = lineCounter() {
^
main.c:23:3: error: expected identifier or '('
rl.on("line", function(line, lineNum = lineCounter() {
  ^
4 warnings and 9 errors generated.

                    
#10
Error de compilación
                      main.c:1:1: error: unknown type name 'var'
var readline = require('readline');
^
main.c:1:16: warning: implicit declaration of function 'require' is invalid in C99 [-Wimplicit-function-declaration]
var readline = require('readline');
               ^
main.c:1:24: warning: multi-character character constant [-Wmultichar]
var readline = require('readline');
                       ^
main.c:1:24: warning: character constant too long for its type
main.c:3:1: error: unknown type name 'var'
var rl = readline.createInterface({
^
main.c:3:35: error: expected expression
var rl = readline.createInterface({
                                  ^
main.c:8:1: error: unknown type name 'function'
function lineCounter(line = 0) {
^
main.c:8:22: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
function lineCounter(line = 0) {
                     ^
main.c:8:27: error: C does not support default arguments
function lineCounter(line = 0) {
                          ^ ~
main.c:12:1: error: unknown type name 'function'
function isSorted(arr) {
^
main.c:13:2: error: use of undeclared identifier 'let'
 let previousItem = Number.POSITIVE_INFINITY
 ^
main.c:23:1: error: unknown type name 'rl'
rl.on("line", function(line, lineNum = lineCounter() {
^
main.c:23:3: error: expected identifier or '('
rl.on("line", function(line, lineNum = lineCounter() {
  ^
4 warnings and 9 errors generated.

                    
#11
Error de compilación
                      main.c:1:1: error: unknown type name 'var'
var readline = require('readline');
^
main.c:1:16: warning: implicit declaration of function 'require' is invalid in C99 [-Wimplicit-function-declaration]
var readline = require('readline');
               ^
main.c:1:24: warning: multi-character character constant [-Wmultichar]
var readline = require('readline');
                       ^
main.c:1:24: warning: character constant too long for its type
main.c:3:1: error: unknown type name 'var'
var rl = readline.createInterface({
^
main.c:3:35: error: expected expression
var rl = readline.createInterface({
                                  ^
main.c:8:1: error: unknown type name 'function'
function lineCounter(line = 0) {
^
main.c:8:22: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
function lineCounter(line = 0) {
                     ^
main.c:8:27: error: C does not support default arguments
function lineCounter(line = 0) {
                          ^ ~
main.c:12:1: error: unknown type name 'function'
function isSorted(arr) {
^
main.c:13:2: error: use of undeclared identifier 'let'
 let previousItem = Number.POSITIVE_INFINITY
 ^
main.c:23:1: error: unknown type name 'rl'
rl.on("line", function(line, lineNum = lineCounter() {
^
main.c:23:3: error: expected identifier or '('
rl.on("line", function(line, lineNum = lineCounter() {
  ^
4 warnings and 9 errors generated.

                    
#12
Error de compilación
                      main.c:1:1: error: unknown type name 'var'
var readline = require('readline');
^
main.c:1:16: warning: implicit declaration of function 'require' is invalid in C99 [-Wimplicit-function-declaration]
var readline = require('readline');
               ^
main.c:1:24: warning: multi-character character constant [-Wmultichar]
var readline = require('readline');
                       ^
main.c:1:24: warning: character constant too long for its type
main.c:3:1: error: unknown type name 'var'
var rl = readline.createInterface({
^
main.c:3:35: error: expected expression
var rl = readline.createInterface({
                                  ^
main.c:8:1: error: unknown type name 'function'
function lineCounter(line = 0) {
^
main.c:8:22: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
function lineCounter(line = 0) {
                     ^
main.c:8:27: error: C does not support default arguments
function lineCounter(line = 0) {
                          ^ ~
main.c:12:1: error: unknown type name 'function'
function isSorted(arr) {
^
main.c:13:2: error: use of undeclared identifier 'let'
 let previousItem = Number.POSITIVE_INFINITY
 ^
main.c:23:1: error: unknown type name 'rl'
rl.on("line", function(line, lineNum = lineCounter() {
^
main.c:23:3: error: expected identifier or '('
rl.on("line", function(line, lineNum = lineCounter() {
  ^
4 warnings and 9 errors generated.

                    
Puntos totales: 0 / 100

Código

var readline = require('readline');

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

function lineCounter(line = 0) {
  return ++line
}
 
function isSorted(arr) {
 let previousItem = Number.POSITIVE_INFINITY
 return arr.some((item, index) => {

   const sorted = item > previousItem || item === previousItem
   previousItem = item
   return sorted
   
 })
}

rl.on("line", function(line, lineNum = lineCounter() {
  if (lineNum === 2) {
    var parts = line.split(" ").map(Number);
    console.log(isSorted(parts) ? "Ordenado" : "Desordenado")
 }
});