69,371
社区成员
发帖
与我相关
我的任务
分享
#include <stdio.h>
#include <math.h>
int get_result(int m, int n)
{
int store;
int count;
if(m==0||m==1||m==5||m==6)
return m;
switch(m)
{
case 2:
store = n%4;
if(n>4)
return pow(2, store)*6;
else
return pow(2, store);
case 3:
store = n%4;
return pow(3, store);
case 4:
store = n%2;
if(store)
return 4;
else
return 6;
case 7:
store = n%4;
return pow(7, store);
case 8:
store = n % 4;
return pow(8, store)*6;
case 9:
store = n%2;
if(store)
return 9;
else
return 1;
}
}
int main()
{
int count,num;
scanf("%d",&count);
while(count--)
{
int result;
int last;
scanf("%d",&num);
last = num % 10;
result=get_result(last, num)%10;
printf("%d\n", result);
}
return 0;
}
#include "stdafx.h"
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main(int argc, char* argv[])
{
int m[100],temp,nNum;
int i=0;
printf("input the sample:\n");
scanf("%d",&nNum);
while(nNum--)
{
scanf("%d",&m[i++]);
}
printf("output thr right most digit :\n");
for(int j=0;j<i;j++)
{ temp=1;
for(int k=0;k<m[j];k++)
{
temp*=m[j];
temp=temp%10;
}
printf("%d\n",temp);
}
return 0;
}
#include "stdlib.h"
int get_last(int d)
{
while ((d %= 10) >= 10)
;
return d;
}
int main()
{
int* data = 0;
int num = 0;
int i = 0;
printf("please input the data : \n");
scanf("%d", &num);
if (num <= 0)
return 1;
data = (int*)malloc(sizeof(int) * num);
while (i < num)
scanf("%d", &data[i++]);
printf("the result is : \n");
for (i = 0; i < num; ++i)
{
int d = data[i];
int j = 0;
int w = get_last(d);
int r = w;
while (++j < d)
r = get_last(r * w);
printf("%d\n", r);
}
free(data);
return 0;
}
-------------
please input the data :
5
1
2
3
4
12345678
the result is :
1
4
7
6
4
请按任意键继续. . .
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main()
{
unsigned m,temp,flag;
while(1)
{
scanf("%d",&m);
if(m>0)
{
temp=pow(m,m);
flag =temp%10;
printf("%d\n",flag);
}
}
return 0;
}