Last active
November 29, 2018 20:26
-
-
Save daniilgri/c248160bd77ff437c61b435f9c7d8c05 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "pch.h" | |
#include <stdio.h> | |
#include <conio.h> | |
#include <windows.h> | |
#include <math.h> | |
void mySort(int* arr, int size); | |
int main() { | |
SetConsoleOutputCP(1251); | |
SetConsoleCP(1251); | |
bool equal = true; | |
const int size = 20; | |
int a[size] = { 5, 2, 50, 4, 5, 6, 7, 3, 334, 0, 12, 4, 13, 14, 15, 16, 17, 18, 19, 20 }; | |
int b[size] = { 5, 2, 50, 4, 5, 6, 7, 3, 334, 0, 12, 4, 13, 14, 15, 16, 17, 18, 19, 20 }; | |
mySort(a, size); | |
mySort(b, size); | |
for (int i = 0; i < size; i++) { | |
if (a[i] != b[i]) { | |
printf("Не равны!"); | |
equal = false; | |
break; | |
} | |
} | |
if (equal) { | |
printf("Равны!"); | |
} | |
_getch(); | |
return 0; | |
} | |
void mySort(int* arr, int size) { | |
int tmp; | |
for (int* i = arr; i < &arr[size - 1]; i++) { | |
for (int* j = arr; j < &arr[size - 1]; j++) { | |
if (*(j + 1) < *j) { | |
tmp = *j; | |
*j = *(j + 1); | |
*(j + 1) = tmp; | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment