猜年龄
结果 :10
1 #include<iostream> 2 using namespace std; 3 4 int main() 5 { 6 int a,b; 7 for(a=1 ; ; a++) 8 { 9 for(b=a+1 ; b<=a+8 ; b++) 10 { 11 if(a*b == (a+b)*6) 12 { 13 cout<<a<<endl; 14 // cout<<b<<endl; 15 return 0; 16 } 17 } 18 } 19 }
猜年龄
结果 :10
1 #include<iostream> 2 using namespace std; 3 4 int main() 5 { 6 int a,b; 7 for(a=1 ; ; a++) 8 { 9 for(b=a+1 ; b<=a+8 ; b++) 10 { 11 if(a*b == (a+b)*6) 12 { 13 cout<<a<<endl; 14 // cout<<b<<endl; 15 return 0; 16 } 17 } 18 } 19 }
相关文章: