CSES - Datatähti 2016 alku - Results
Submission details
Task:Kirjat
Sender:KARHU
Submission time:2015-10-05 21:52:24
Language:C++
Status:COMPILE ERROR

Compiler report

input/code.cpp: In function 'int main()':
input/code.cpp:29:43: error: expected ';' before ']' token
         kaaleppi[i] = (i + rand()) % maara];
                                           ^
input/code.cpp:11:12: warning: unused variable 'j' [-Wunused-variable]
     int i, j, k;
            ^
input/code.cpp:15:32: warning: ignoring return value of 'int fscanf(FILE*, const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     fscanf(stdin, "%d", &maara);
                                ^
input/code.cpp:19:40: warning: ignoring return value of 'int fscanf(FILE*, const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         fscanf(stdin, "%d", &uolevi[i]);
                                        ^
input/code.cpp:23:39: warning: ignoring return value of 'int fscanf(FILE*, const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         fscanf(stdin, "%d", &maija[i]);

Code

#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>

// g++ ...
#define __STDC_FORMAT_MACROS
#include <inttypes.h>

int main()
{
    int i, j, k;
    int maara;
    int *uolevi, *maija, *kaaleppi;

    fscanf(stdin, "%d", &maara);

    uolevi = (int*)malloc(maara * sizeof(int));
    for(i = 0; i < maara; ++i)
        fscanf(stdin, "%d", &uolevi[i]);

    maija = (int*)malloc(maara * sizeof(int));
    for(i = 0; i < maara; ++i)
        fscanf(stdin, "%d", &maija[i]);

    kaaleppi = (int*)malloc(maara * sizeof(int));
    k = 1;
    for(i = 0; i < maara; ++i)
    {
        kaaleppi[i] = (i + rand()) % maara];
    }

    for(i = 0; i < maara; ++i)
        printf("%u ", kaaleppi[i]);

    free(uolevi);
    free(maija);
    free(kaaleppi);

    return 0;
}