《软件工程》 第三周 作业(一)

1. 学习在coding 上注册、配置及管理方法;将链接发送到助教-刘乾的博客  

       http://www.cnblogs.com/siviltaram/p/5264700.html ;

    将上次完成作业的四则运算程序上传至coding系统中; 该作业截止日期:3月17 日(周三 晚 20点前)

2.

阅读下面程序,请回答如下问题:

问题1:这个程序要找的是符合什么条件的数?

问题2:这样的数存在么?符合这一条件的最小的数是什么?

问题3:在电脑上运行这一程序,你估计多长时间才能输出第一个结果?时间精确到分钟(电脑:单核CPU 4.0G Hz,内存和硬盘等资源充足)。

问题4:在多核电脑上如何提高这一程序的运行效率?

(注:该程序、用C#语言编写,但是只要有C语言基础完全没有阅读压力,如果对部分语句不懂请自行查询)

要求:将上述问题结果写到博客上。

using System;

using System.Collections.Generic;

using System.Text;

namespace FindTheNumber

{
  class Program
  {
    static void Main(string[] args)
    {
      int [] rg =
          {2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,
           20,21,22,23,24,25,26,27,28,29,30,31};
      for (Int64 i = 1; i < Int64.MaxValue; i++)
      {
        int hit = 0;
        int hit1 = -1;
        int hit2 = -1;
        for (int j = 0; (j < rg.Length) && (hit <=2) ; j++)
        {
          if ((i % rg[j]) != 0)
          {
            hit++;
            if (hit == 1)
            {
              hit1 = j;
            }
            else if (hit == 2)
            {
              hit2 = j;
            }
            else
              break;
          }

        }
        if ((hit == 2)&& (hit1+1==hit2))
        {
          Console.WriteLine("found {0}", i);
        }
      }
    }
  }
}

3. 编写教科书2.4.2 wordcount程序,请按要求编写,注意代码规范,并将程序上传至coding系统。

4. 本次作业截止时间(作业1:3月17 日(周三  20点前),  作业2,3:3月21日 (周一  22点前))

原文地址:https://www.cnblogs.com/qingxu/p/5279438.html