Submission #307494

# Submission time Handle Problem Language Result Execution time Memory
307494 2020-09-28T11:12:03 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()
{
srand(time(NULL));

uint8_t swap = 0;
uint8_t * tasks = {0,1,2,3,4,5,6,7,8,9};
uint8_t * cpy_tasks;
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++)
{
    temp = tasks[i];
    if(tasks[i] != cpy_tasks[deadline[i]])
    {
    tasks[i] = cpy_tasks[deadline[i]]; 
    swap+=task[i];
    }
    tasks[deadline[i]] = temp; 
}


    return 0;
}

Compilation message

Main.c: In function 'main':
Main.c:9:7: warning: implicit declaration of function 'time' [-Wimplicit-function-declaration]
    9 | srand(time(NULL));
      |       ^~~~
Main.c:12:22: warning: excess elements in scalar initializer
   12 | uint8_t * tasks = {0,1,2,3,4,5,6,7,8,9};
      |                      ^
Main.c:12:22: note: (near initialization for 'tasks')
Main.c:12:24: warning: excess elements in scalar initializer
   12 | uint8_t * tasks = {0,1,2,3,4,5,6,7,8,9};
      |                        ^
Main.c:12:24: note: (near initialization for 'tasks')
Main.c:12:26: warning: excess elements in scalar initializer
   12 | uint8_t * tasks = {0,1,2,3,4,5,6,7,8,9};
      |                          ^
Main.c:12:26: note: (near initialization for 'tasks')
Main.c:12:28: warning: excess elements in scalar initializer
   12 | uint8_t * tasks = {0,1,2,3,4,5,6,7,8,9};
      |                            ^
Main.c:12:28: note: (near initialization for 'tasks')
Main.c:12:30: warning: excess elements in scalar initializer
   12 | uint8_t * tasks = {0,1,2,3,4,5,6,7,8,9};
      |                              ^
Main.c:12:30: note: (near initialization for 'tasks')
Main.c:12:32: warning: excess elements in scalar initializer
   12 | uint8_t * tasks = {0,1,2,3,4,5,6,7,8,9};
      |                                ^
Main.c:12:32: note: (near initialization for 'tasks')
Main.c:12:34: warning: excess elements in scalar initializer
   12 | uint8_t * tasks = {0,1,2,3,4,5,6,7,8,9};
      |                                  ^
Main.c:12:34: note: (near initialization for 'tasks')
Main.c:12:36: warning: excess elements in scalar initializer
   12 | uint8_t * tasks = {0,1,2,3,4,5,6,7,8,9};
      |                                    ^
Main.c:12:36: note: (near initialization for 'tasks')
Main.c:12:38: warning: excess elements in scalar initializer
   12 | uint8_t * tasks = {0,1,2,3,4,5,6,7,8,9};
      |                                      ^
Main.c:12:38: note: (near initialization for 'tasks')
Main.c:24:11: error: 'task' undeclared (first use in this function); did you mean 'tasks'?
   24 |     swap+=task[i];
      |           ^~~~
      |           tasks
Main.c:24:11: note: each undeclared identifier is reported only once for each function it appears in
Main.c:11:9: warning: variable 'swap' set but not used [-Wunused-but-set-variable]
   11 | uint8_t swap = 0;
      |         ^~~~