Design the test cases

上一篇 / 下一篇  2011-09-14 21:07:54

Design the test cases to make sure that all the following statements will be executed at least one time.

int IsLeap (int year)

{

if (year %4 == 0)

{

    if( year % 100 == 0)

    {

       if (year % 400 ==0)

           Leap = 1

      else

             Leap = 0;

      }

     Leap = 1;

 }

Leap = 0;

 

return leap;

}

 

Answer:

      Case1: year =

      Case2: year =

      Case3: year =

      Case4: year =

   


TAG:

非常夏日的个人空间 引用 删除 非常夏日   /   2011-09-15 19:01:17
Design the test cases to make sure that all the following statements will be executed at least one time.

int IsLeap (int year)
{
if (year %4 == 0)
{
    if( year % 100 == 0)
    {
       if (year % 400 ==0)
           Leap = 1
      else
             Leap = 0;
      }
     Leap = 1;
}
Leap = 0;


return leap;
}


Answer:
      Case1: year =?
      Case2: year =?
      Case3: year =?
      Case4: year =?
   

zhengyuhui KF49763(zkf49763)   2011-09-15 16:13:01
//1.能被4 整队,但不能被100 整除的年份都是闰年。 2.能被100 整除,又能被400 整除的年份是闰年。
    //0表示闰年,1表示非闰年
    int IsLeap(int year)
    {
        int leap = 1;
        if (year % 4 == 0)
        {
            if (year % 100 == 0)
            {
                if (year % 400 == 0)
                {
                    //能被100 整除,又能被400 整除的年份是闰年
                    leap = 0;
                }
                else
                {
                    //不是闰年
                    leap = 1;
                }
            }
            else
            {
                //闰年  能被4 整队,但不能被100 整除的年份都是闰年
                leap = 0;
            }
            
        }
        
        return leap;
    }
 

评分:0

我来说两句

日历

« 2024-05-09  
   1234
567891011
12131415161718
19202122232425
262728293031 

数据统计

  • 访问量: 563
  • 日志数: 7
  • 建立时间: 2011-09-07
  • 更新时间: 2011-10-12

RSS订阅

Open Toolbar