Last active
March 4, 2019 12:22
-
-
Save gavr123456789/7fe4edfbc954080ce44e9ddcf08ecc3e to your computer and use it in GitHub Desktop.
This file contains hidden or 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
void main(string[] args) { | |
int[] e = {}; | |
for (int i=0,j=0;i<100;i++,j++) { | |
e+=j;e+=j;//заполнение парными | |
} | |
e+=100003;//уникальный | |
ulong micsec; | |
double sec; | |
Timer timer = new Timer ();//засекаем время | |
firstMethod(e); timer.stop (); | |
sec = timer.elapsed (out micsec); | |
print (@"\nsec = $sec, microsec = $micsec"); | |
timer.reset();//ресет времени | |
secondMethod(e); timer.stop(); | |
sec = timer.elapsed (out micsec); | |
print (@"\nsec2 = $sec, microsec2 = $micsec"); | |
} | |
void firstMethod(int[] arr){ | |
int f=0; | |
for (int i=0; i<arr.length; i++) { | |
f = 1; | |
for (int j=0; j<arr.length; j++) | |
if (arr[i] == arr[j] && i != j) { | |
f = 0;break;} | |
if (f == 1) print(@"first $(arr[i]) "); | |
} | |
} | |
void secondMethod(int[] arr){ | |
int f=arr[0]; print("\n"); | |
int result=0; | |
for (int i=1;i<arr.length;i++) | |
result ^= arr[i]; | |
print(@"second $result"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment