Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Ultima cifra a lui a^b
- unsigned uc(unsigned a, unsigned b)
- {
- unsigned c=a%10;
- if(c==0 || c==1 || c==5 || c==6)
- return c;
- else
- switch(c)
- {
- case 2:
- {
- switch(b%4)
- {
- case 0:
- return 6;
- case 1:
- return 2;
- case 2:
- return 8;
- case 3:
- return c;
- }
- }
- case 3:
- {
- switch(b%4)
- {
- case 0:
- return 6;
- case 1:
- return 2;
- case 2:
- return 8;
- case 3:
- return c;
- }
- }
- case 4:
- {
- switch(b%4)
- {
- case 0:
- return 6;
- case 1:
- return 2;
- case 2:
- return 8;
- case 3:
- return c;
- }
- }
- case 7:
- {
- switch(b%4)
- {
- case 0:
- return 6;
- case 1:
- return 2;
- case 2:
- return 8;
- case 3:
- return c;
- }
- }
- case 8:
- {
- switch(b%4)
- {
- case 0:
- return 6;
- case 1:
- return 2;
- case 2:
- return 8;
- case 3:
- return c;
- }
- }
- case 9:
- {
- switch(b%4)
- {
- case 0:
- return 6;
- case 1:
- return 2;
- case 2:
- return 8;
- case 3:
- return c;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement