From a5483b2cd860cff23da64ffa565ff16fe08525a0 Mon Sep 17 00:00:00 2001 From: Mikita Sidarenka Date: Fri, 8 Apr 2022 09:27:38 +0000 Subject: [PATCH] Add 'du5/program.c' --- du5/program.c | 116 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 116 insertions(+) create mode 100644 du5/program.c diff --git a/du5/program.c b/du5/program.c new file mode 100644 index 0000000..da257d4 --- /dev/null +++ b/du5/program.c @@ -0,0 +1,116 @@ +#include +#include +#include +bool similar = false; +bool wrong = false; +struct x1 +{ + int idx; + char array[60]; +}; +int main(){ + struct x1 x1[50]; + int n_p = 0; + int i1=0; + while(i1 >=0) + { + i1=i1+1; + char idx1[60]; + int idx2 =0; + int nikita = scanf("%d", &idx2); + if (nikita == -1) + { + break; + } + if (idx2 == 0) + { + wrong = true; + } + + fgets(idx1, 60 , stdin); + int g=0; + while (g x1[dima].array[1]){ + int sidorenko = x1[i].idx; + char tmp_name[60]; + strcpy(tmp_name, x1[i].array); + x1[i].idx = x1[dima].idx; + strcpy(x1[i].array, x1[dima].array); + x1[dima].idx = sidorenko; + strcpy(x1[dima].array, tmp_name); + } + if(x1[i].array[1] == x1[dima].array[1]) + { + if(x1[i].array[2] > x1[dima].array[2]){ + int sidorenko = x1[i].idx; + char tmp_name[60]; + strcpy(tmp_name, x1[i].array); + x1[i].idx = x1[dima].idx; + strcpy(x1[i].array, x1[dima].array); + x1[dima].idx = sidorenko; + strcpy(x1[dima].array, tmp_name); + } + } + } + } + } + + printf("Vysledky:\n"); + int i3=0; + while (i3 < n_p) + { + i3=i3+1; + printf("%d", x1[i].idx); + printf("%s", x1[i].array); + } + + return 0; +} \ No newline at end of file