Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Prosta implementacja algorytmu Euklidesa (NWD)
//Prosta implementacja algorytmu Euklidesa (NWD) #include <utility> /* Zwraca wartość bezwględną argumentu */ template<typename T> inline auto abs(const T& t) { if(t<0) return -t; else return t; } int NWD(int a, int b) { a = abs(a); b = abs(b); if(a<b) std::swap(a, b); while(b){ const int reszta = a%b; a = b; b = reszta; } return a; } #include <iostream> int main() { int a, b; while(std::cin >> a >> b) std::cout << NWD(a, b) << '\n'; }
run
|
edit
|
history
|
help
0
remove_copy_if-30-Seconds-of-C++
substring search
codechef
Bin Tree build
Power of an element
Odwrócone podciągi
Deque RotateString
32bit
Вывод элементов массива
Polyrmophism