Submission #307511

# Submission time Handle Problem Language Result Execution time Memory
307511 2020-09-28T12:12:37 Z giorgigagua2006 Exercise Deadlines (CCO20_day1problem2) C
Compilation error
0 ms 0 KB
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#define task_count 10

int main()
{

uint8_t swap = 0;
uint8_t * tasks = {0,1,2,3,4,5,6,7,8,9};
uint8_t * cpy_tasks = {0,1,2,3,4,5,6,7,8,9};
uint8_t deadline[] = {2,3,7,1,5,4,9,0,6,8};
memcpy(cpy_tasks, tasks, 10);
uint8_t temp;

for (size_t i = 0; i < task_count; i++)
{
    if(tasks[i] != cpy_tasks[deadline[i]])
    {
    temp = tasks[i];
    tasks[i] = cpy_tasks[deadline[i]]; 
    swap += deadline[i] - i;
    tasks[deadline[i]] = temp; 
    }
}

cout<<Swap;
    return 0;
}

Compilation message

Main.c: In function 'main':
Main.c:11:22: warning: excess elements in scalar initializer
   11 | uint8_t * tasks = {0,1,2,3,4,5,6,7,8,9};
      |                      ^
Main.c:11:22: note: (near initialization for 'tasks')
Main.c:11:24: warning: excess elements in scalar initializer
   11 | uint8_t * tasks = {0,1,2,3,4,5,6,7,8,9};
      |                        ^
Main.c:11:24: note: (near initialization for 'tasks')
Main.c:11:26: warning: excess elements in scalar initializer
   11 | uint8_t * tasks = {0,1,2,3,4,5,6,7,8,9};
      |                          ^
Main.c:11:26: note: (near initialization for 'tasks')
Main.c:11:28: warning: excess elements in scalar initializer
   11 | uint8_t * tasks = {0,1,2,3,4,5,6,7,8,9};
      |                            ^
Main.c:11:28: note: (near initialization for 'tasks')
Main.c:11:30: warning: excess elements in scalar initializer
   11 | uint8_t * tasks = {0,1,2,3,4,5,6,7,8,9};
      |                              ^
Main.c:11:30: note: (near initialization for 'tasks')
Main.c:11:32: warning: excess elements in scalar initializer
   11 | uint8_t * tasks = {0,1,2,3,4,5,6,7,8,9};
      |                                ^
Main.c:11:32: note: (near initialization for 'tasks')
Main.c:11:34: warning: excess elements in scalar initializer
   11 | uint8_t * tasks = {0,1,2,3,4,5,6,7,8,9};
      |                                  ^
Main.c:11:34: note: (near initialization for 'tasks')
Main.c:11:36: warning: excess elements in scalar initializer
   11 | uint8_t * tasks = {0,1,2,3,4,5,6,7,8,9};
      |                                    ^
Main.c:11:36: note: (near initialization for 'tasks')
Main.c:11:38: warning: excess elements in scalar initializer
   11 | uint8_t * tasks = {0,1,2,3,4,5,6,7,8,9};
      |                                      ^
Main.c:11:38: note: (near initialization for 'tasks')
Main.c:12:26: warning: excess elements in scalar initializer
   12 | uint8_t * cpy_tasks = {0,1,2,3,4,5,6,7,8,9};
      |                          ^
Main.c:12:26: note: (near initialization for 'cpy_tasks')
Main.c:12:28: warning: excess elements in scalar initializer
   12 | uint8_t * cpy_tasks = {0,1,2,3,4,5,6,7,8,9};
      |                            ^
Main.c:12:28: note: (near initialization for 'cpy_tasks')
Main.c:12:30: warning: excess elements in scalar initializer
   12 | uint8_t * cpy_tasks = {0,1,2,3,4,5,6,7,8,9};
      |                              ^
Main.c:12:30: note: (near initialization for 'cpy_tasks')
Main.c:12:32: warning: excess elements in scalar initializer
   12 | uint8_t * cpy_tasks = {0,1,2,3,4,5,6,7,8,9};
      |                                ^
Main.c:12:32: note: (near initialization for 'cpy_tasks')
Main.c:12:34: warning: excess elements in scalar initializer
   12 | uint8_t * cpy_tasks = {0,1,2,3,4,5,6,7,8,9};
      |                                  ^
Main.c:12:34: note: (near initialization for 'cpy_tasks')
Main.c:12:36: warning: excess elements in scalar initializer
   12 | uint8_t * cpy_tasks = {0,1,2,3,4,5,6,7,8,9};
      |                                    ^
Main.c:12:36: note: (near initialization for 'cpy_tasks')
Main.c:12:38: warning: excess elements in scalar initializer
   12 | uint8_t * cpy_tasks = {0,1,2,3,4,5,6,7,8,9};
      |                                      ^
Main.c:12:38: note: (near initialization for 'cpy_tasks')
Main.c:12:40: warning: excess elements in scalar initializer
   12 | uint8_t * cpy_tasks = {0,1,2,3,4,5,6,7,8,9};
      |                                        ^
Main.c:12:40: note: (near initialization for 'cpy_tasks')
Main.c:12:42: warning: excess elements in scalar initializer
   12 | uint8_t * cpy_tasks = {0,1,2,3,4,5,6,7,8,9};
      |                                          ^
Main.c:12:42: note: (near initialization for 'cpy_tasks')
Main.c:28:1: error: 'cout' undeclared (first use in this function)
   28 | cout<<Swap;
      | ^~~~
Main.c:28:1: note: each undeclared identifier is reported only once for each function it appears in
Main.c:28:7: error: 'Swap' undeclared (first use in this function); did you mean 'swap'?
   28 | cout<<Swap;
      |       ^~~~
      |       swap