tim 2 so cuoi cua n^m
/*tim hai so cuoi cua n mu m*/
#include<stdio.h>
#include<conio.h>
#include<math.h>
int luythua(int n,int m)
{
int i,t=1;
for(i=1;i<=m;i++)
{
t=t*n;
}
return t;/*chay tu 1 den m, moi lan nhan vs chinh no=>luy thua*/
}/*co the dung ham pow(x,y) thay the nhung vs so lon thi ko chinh xac*/
int main()
{
long n,m;
long a,b;
printf("nhap n= ");scanf("%d",&n);
printf("nhap m= ");scanf("%d",&m);
a=luythua(n,m);
printf("%d luy thua %d la %d
",n,m,a);
b=a%100;/*lay phan du la 2 so*/
if(b>=10)
printf("hai so cuoi cua %d luy thua %d la : %d",n,m,b);/*neu 2 so cuoi lon hon 10 thi in*/
else
printf("hai so cuoi cua %d luy thua %d la : 0%d",n,m,b);/*neu 2 so cuoi nho hon 10 thi them 0 truoc*/
getch();
return 0;
}
Bạn đang đọc truyện trên: AzTruyen.Top