64,647
社区成员
发帖
与我相关
我的任务
分享
while(c)
{
c /= n;//就体现在里面两句。逆向思维。
++n; //
}
#include <iostream>
using namespace std;
int main()
{
int a,b,c,n=1;
cout<<"please enter a and b"<<endl;
cin>>a>>b;
c = a * b;
while(c)
{
c /= n;
++n;
}
cout<<a<<"*"<<b<<"<"<<n-1<<"!"<<endl;
return 0;
}
/////////////////////////////////////////
please enter a and b
1 1
1*1<2!
Press any key to continue
please enter a and b
10 10
10*10<5!
Press any key to continue
please enter a and b
12 12
12*12<6!
Press any key to continue
please enter a and b
100 100
100*100<8!
Press any key to continue
please enter a and b
100 100
100*100<8!
Press any key to continue
int n = 1;
int c = a*b;
while(c)
{
c /= n;
++n;
}