Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <conio.h>
- using namespace std;
- template <unsigned A, unsigned B>
- struct pNWD
- {
- enum
- {
- wartosc = pNWD<B, A%B>::wartosc
- };
- };
- template <unsigned A>
- struct pNWD<A, 0>
- {
- enum
- {
- wartosc = A
- };
- };
- template <unsigned A, unsigned B>
- struct MAX
- {
- enum
- {
- w=(A>B) ? A : B
- };
- };
- template <unsigned A, unsigned B>
- struct MIN
- {
- enum
- {
- w=(A<B) ? A : B
- };
- };
- template <unsigned A, unsigned B>
- struct NWD
- {
- enum
- {
- wartosc = pNWD< MAX<A, B>::w, MIN<A, B>::w >::wartosc
- };
- };
- int main()
- {
- cout<<NWD<23*123, 23*997>::wartosc<<endl;
- getch();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement