给出一个整数N,输出N^N(N的N次方)的十进制表示的末位数字。
Input
一个数N(1 <= N <= 10^9)
Output
输出N^N的末位数字
Input示例
13
Output示例
3

一道规律题,幂的末位数的规律为四次一循环,所以……

#include <stdio.h>
#include <math.h>

int main()
{
    int a, b, c;
    scanf("%d", &a);
    b = a % 10;
    //幂的末尾数字规律为4个一循环
    c = a % 4;
    //c等于0时为第四个
    if (c == 0)
        c = 4;
    c = pow(b, c);
    printf("%d", c % 10);
    return 0;
}