t;<(n-1)/3<<"*3+1="<<n<<endl;
}
else
{
n/=2;
cout<<"Step No."<<++cnt<<":"<<2*n<<"/2="<<n<<endl;
}
} while(__________); // (3)
cout<<endl;
}
return 0;
}
3.四方定理
This program is to verify Theorem of Four Squares.That is all natural numbers can be represented as sum of no more than 4 squares of the numbers.e.g., 123=7*7+7*7+4*4+3*3.
#include <iostream>
using namespace std;
int main()
{
int i,j,k,l,number;
while(1)
{
cout<<"Please input a number to verify(0 to quit): ";
cin>>number;
if(number==0) __________; // (1)
cout<<" ------ Results of verification: ------------\n";
for(i=1;i<=number/2;i++)
for(j=0;j<=i;j++)
for(k=0;k<=j;k++)
for(l=0;l<=k;l++)
if(__________) // (2)
{
cout<<number<<"="<<i<<"*"<<i<<"+"<<j<<"*"<<j<<"+"<<k<<"*"<<k<<"+"<<l<<"*"<<l<<endl;
goto exit;
}
exit: cout<<" ---------------------------------------------\