As the title~
Xiao Ming took his two younger sisters to the Lantern Festival. When someone asked them how old they were, they said mischievously: "The product of our age is 6 times the sum of our ages."
Xiao Ming added: "They are not twins, and the difference in age must be no more than 8 years old."
Please write: the age of Xiao Ming's younger sister.
This question is relatively simple, just go to the code
#include <stdio.h>
int main()
{
int i,j;
for(i=1;i<25;i++)//先定义妹妹多大了 ,一猜就估计妹妹不超过25
{
for(j=1;j<33;j++)//姐姐多大了, 妹妹不超过25,姐姐不超过33
{
if(j-i>0&&j-i<8&&i*j==6*(i+j))
{
printf("%d",i);
}
}
}
}
Run screenshot: The
answer is 10