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
begin_end.cpp
Value equal to index value
My Type - nicro
BST to DLL
Goooood
codechef
LRU - template
PhB
bmp_lb
static_cast makes a copy