From 45fc4c1d3d27e79fd80684b1a0200ed2f743f4db Mon Sep 17 00:00:00 2001 From: Artem Horbunov Date: Tue, 7 Apr 2020 14:45:58 +0000 Subject: [PATCH] =?UTF-8?q?Aktualizovat=20=E2=80=9Edu5/program.c=E2=80=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- du5/program.c | 68 +++++++++++++++++++++++++-------------------------- 1 file changed, 34 insertions(+), 34 deletions(-) diff --git a/du5/program.c b/du5/program.c index c045e27..72ccbdc 100644 --- a/du5/program.c +++ b/du5/program.c @@ -41,46 +41,46 @@ int main(){ } } - for(int i = 0; i < newPos - 1; i++){ - if(newScore[i] < newScore[i + 1]){ - int tmpScore = newScore[i]; - newScore[i] = newScore[i + 1]; - newScore[i + 1] = tmpScore; + for(int d = 0; d < newPos - 1; d++){ + for(int i = 0; i < newPos - 1; i++){ + if(newScore[i] < newScore[i + 1]){ + int tmpScore = newScore[i]; + newScore[i] = newScore[i + 1]; + newScore[i + 1] = tmpScore; - char tmpName[50]; - strcpy(tmpName, newName[i]); - strcpy(newName[i], newName[i + 1]); - strcpy(newName[i + 1], tmpName); + char tmpName[50]; + strcpy(tmpName, newName[i]); + strcpy(newName[i], newName[i + 1]); + strcpy(newName[i + 1], tmpName); - i = -1; - } - else if(newScore[i] == newScore[i + 1]){ - int test = 0; - for(int q = 0; q < newPos; q++){ - if(newName[i][pos] < newName[i + 1][pos]){ - int tmpScore = newScore[i]; - newScore[i] = newScore[i + 1]; - newScore[i + 1] = tmpScore; + } + else if(newScore[i] == newScore[i + 1]){ + int test = 0; + for(int q = 0; q < newPos; q++){ + if(newName[i][pos] < newName[i + 1][pos]){ + int tmpScore = newScore[i]; + newScore[i] = newScore[i + 1]; + newScore[i + 1] = tmpScore; - char tmpName[50]; - strcpy(tmpName, newName[i]); - strcpy(newName[i], newName[i + 1]); - strcpy(newName[i + 1], tmpName); - break; - } - else{ - int tmpScore = newScore[i + 1]; - newScore[i + 1] = newScore[i]; - newScore[i] = tmpScore; + char tmpName[50]; + strcpy(tmpName, newName[i]); + strcpy(newName[i], newName[i + 1]); + strcpy(newName[i + 1], tmpName); + break; + } + else{ + int tmpScore = newScore[i + 1]; + newScore[i + 1] = newScore[i]; + newScore[i] = tmpScore; - char tmpName[50]; - strcpy(tmpName, newName[i + 1]); - strcpy(newName[i + 1], newName[i]); - strcpy(newName[i], tmpName); - break; + char tmpName[50]; + strcpy(tmpName, newName[i + 1]); + strcpy(newName[i + 1], newName[i]); + strcpy(newName[i], tmpName); + break; + } } } - i = -1; } }