답안 #307513

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
307513 2020-09-28T12:19:48 Z giorgigagua2006 Exercise Deadlines (CCO20_day1problem2) C
0 / 25
0 ms 256 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[task_count] = {0,1,2,3,4,5,6,7,8,9};
uint8_t * cpy_tasks = (uint8_t *)malloc(task_count);
uint8_t deadline[task_count] = {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; 
    }
}
printf("%d", swap);

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -