设为首页 加入收藏

TOP

程序填空题(二)(一)
2019-06-05 20:08:06 】 浏览:273
Tags:程序 填空

1.尼科彻斯定理

This program is to verify Theorem of Nicoqish.That is the cube of any integer can be represented as the sum of some continue odd numbers.For example, 8^3=512=57+59+61+63+65+67+69+71.

#include <iostream>

using namespace std;

int main()

{

    int n,a,i;

    while(1)

    {

           cout<<"Please input a integer to verify(0 to quit): ";

           cin>>n;

               if(n==0)  __________;                  //  (1)

        // 输出等差数列,首项为a*a-a+1,公差为2,项数为n

               a=n*n-n+1;

        cout<<n<<"*"<<n<<"*"<<n<<"="<<n*n*n<<"="<<a;

        for (i=1; __________;i++)              //  (2)

                     cout<<"+"<<__________;      //  (3)

        cout<<endl;

    }

       return 0;

}

 

2.角谷猜想

This program is to verify Jiaogu Guess.That is given any natural number, if it is an even, divides 2, if it is an odd, multiple 3 and add 1, the result continues to be calculated analogously. After some times, the result is always 1.

#include <iostream>

using namespace std;

int main()

{

    int n,a,i,cnt;

    while(1)

    {

           cout<<"Please input a integer to verify(0 to quit): ";

           cin>>n;

              if(n==0)  __________break;        //  (1)

              cnt=0;

           cout<<" ------ Results of verification: ------------\n";

           do{

               if(__________)     //  (2)

               {

                   n=n*3+1;

                      cout<<"Step No."<<++cnt<<":"&l

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

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目