Run Code
|
API
|
Code Wall
|
Users
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Blog
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
Please
log in
to post a comment.
Trapping rain water problem
2
abhilash
Cuantos
find duplicate in O(n)
code
dijkstra
Policy based smart pointer
SEGMENTED SIEVE
MyStack
Please log in to post a comment.