设为首页 加入收藏

TOP

程序填空题(二)(二)
2019-06-05 20:08:06 】 浏览:274
Tags:程序 填空
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<<" ---------------------------------------------\

首页 上一页 1 2 3 4 5 6 7 下一页 尾页 2/8/8
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇P2801 教主的魔法 下一篇c++ 判断点和圆位置关系(类的声..

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目