From d26f313f9d2707f2794e7f384573baac0bea4479 Mon Sep 17 00:00:00 2001 From: Bohdan Yanchyk Date: Thu, 16 Apr 2020 07:39:38 +0000 Subject: [PATCH] =?UTF-8?q?Aktualizovat=20=E2=80=9Edu6/program.c=E2=80=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- du6/program.c | 203 +++++++++++++++++++++++++------------------------- 1 file changed, 102 insertions(+), 101 deletions(-) diff --git a/du6/program.c b/du6/program.c index 518d969..a0c2a72 100644 --- a/du6/program.c +++ b/du6/program.c @@ -1,101 +1,102 @@ -/****************************************************************************** - -Welcome to GDB Online. -GDB online is an online compiler and debugger tool for C, C++, Python, Java, PHP, Ruby, Perl, -C#, VB, Swift, Pascal, Fortran, Haskell, Objective-C, Assembly, HTML, CSS, JS, SQLite, Prolog. -Code, Compile, Run and Debug online from anywhere in world. - -*******************************************************************************/ -#include -#include -#include -#define fullSIZE = 1000 -#define wSIZE = 100 -#include - -int main() -{ - int SIZE = 0; - if(!(scanf("%d", &SIZE))){ - printf("Nespravny vstup\n"); - return 0; - } - if(SIZE < 1){ - printf("Nespravny vstup\n"); - return 0; - } - int pm = 0; - char** pole_smernikov = malloc(fullSIZE * sizeof(char)); - char* success[SIZE]; - char* unsuccess[SIZE]; - //memset(pole_smernikov,0,SIZE*sizeof(char*)); - int k = 0; - char* line = malloc(wSIZE * sizeof(char)); - memset(line,0,SIZE); - char* r; - int q = 0; - int pocet_znakov = 0; - while (fgets(line,SIZE,stdin)) { - pocet_znakov = strlen(line); - char* all = malloc(pocet_znakov); - memcpy(all, line, pocet_znakov); - for(int x = 0; x < pm; x++){ - if(memcmp(pole_smernikov[x], line, pocet_znakov) == 0){ - k++; - } - pole_smernikov[k] = line; - } - if(0 == k){ - pole_smernikov[pm] = all; - pm++; - } - } - k = 0; - int i = 0; - while (i < pm){ - for(int j = 0+1; j < pm-i; j++){ - if(0 < strcmp(pole_smernikov[j-1], pole_smernikov[j])){ - char* temp = pole_smernikov[j]; - pole_smernikov[j] = pole_smernikov[j - 1]; - pole_smernikov[j-1] = temp; - } - } - // if (memcmp(pole_smernikov[i],line,pocet_znakov)){ - // // Nasiel som - // unsuccess[k] = pole_smernikov[i]; - // printf("%s\n", unsuccess[k]); - // } else{ - // success[q] = pole_smernikov[i]; - // printf("%s\n", success[q]); - - // } - i++; - } - if(NULL == pole_smernikov[1]){ - puts("Ziadne prihlasky"); - return 0; - } - puts("Prijati studenti:"); - for(int i = 0; i < SIZE; i++){ - if(pole_smernikov[i] == NULL){ - break; - } else{ - printf("%s\n", pole_smernikov[i]); - } - free(pole_smernikov[i]); - } - int rra = -1; - pm = pm + rra; - if(0 > (SIZE - pm)){ - puts("Neprijati studenti:"); - for(int i = SIZE+1; i +#include +#include +#define fullSIZE 1000 +#define wSIZE 100 +#include + +int main() +{ + int SIZE = 0; + if(!(scanf("%d", &SIZE))){ + printf("Nespravny vstup\n"); + return 0; + } + if(SIZE < 1){ + printf("Nespravny vstup\n"); + return 0; + } + int pm = 0; + char** pole_smernikov = malloc(fullSIZE * sizeof(char)); + //char* success[SIZE]; + //char* unsuccess[SIZE]; + //memset(pole_smernikov,0,SIZE*sizeof(char*)); + int k = 0; + char* line = malloc(wSIZE * sizeof(char)); + memset(line,0,SIZE); + //char* r; + //int q = 0; + int pocet_znakov = 0; + while (fgets(line,SIZE,stdin)) { + pocet_znakov = strlen(line); + char* all = malloc(pocet_znakov); + memcpy(all, line, pocet_znakov); + for(int x = 0; x < pm; x++){ + if(memcmp(pole_smernikov[x], line, pocet_znakov) == 0){ + k++; + } + pole_smernikov[k] = line; + } + if(0 == k){ + pole_smernikov[pm] = all; + pm++; + } + } + k = 0; + int i = 0; + i = 0; + while (i < pm){ + for(int j = 0+1; j < pm-i; j++){ + if(0 < strcmp(pole_smernikov[j-1], pole_smernikov[j])){ + char* temp = pole_smernikov[j]; + pole_smernikov[j] = pole_smernikov[j - 1]; + pole_smernikov[j-1] = temp; + } + } + // if (memcmp(pole_smernikov[i],line,pocet_znakov)){ + // // Nasiel som + // unsuccess[k] = pole_smernikov[i]; + // printf("%s\n", unsuccess[k]); + // } else{ + // success[q] = pole_smernikov[i]; + // printf("%s\n", success[q]); + + // } + i++; + } + if(NULL == pole_smernikov[1]){ + puts("Ziadne prihlasky"); + return 0; + } + puts("Prijati studenti:"); + for(int i = 0; i < SIZE; i++){ + if(pole_smernikov[i] == NULL){ + break; + } else{ + printf("%s\n", pole_smernikov[i]); + } + free(pole_smernikov[i]); + } + int rra = -1; + pm = pm + rra; + if(0 > (SIZE - pm)){ + puts("Neprijati studenti:"); + for(int i = SIZE+1; i