1.16 phan tich thanh tong 2 cp
#include<stdio.h>
#include<conio.h>
#include<math.h>
int i,a,b,k,n,x,y=0;
int ktcp(int x);
main()
{
printf("Nhap n:
");
scanf("%d", &n);
for (a=0;a<n;a++)
for (b=0;b<n;b++)
{
if ((ktcp(a))&&(ktcp(b))&&(n==a*a+b*b))
y++;
}
if (y==0)
printf("%d khong the phan tich thanh tong bp cua 2 so cp ", n);
else
printf("%d co the phan tich duoc thanh tong bp cua 2 so cp ",n);
getch();
return y;
}
int ktcp(int x)
{
if ((int)(sqrt(x))==sqrt(x))
return 1;
else
return 0;
}
Bạn đang đọc truyện trên: Truyen4U.Com